Modified to initialize the krb5 principal type information. Also modified
authorTheodore Tso <tytso@mit.edu>
Thu, 24 Sep 1992 23:22:13 +0000 (23:22 +0000)
committerTheodore Tso <tytso@mit.edu>
Thu, 24 Sep 1992 23:22:13 +0000 (23:22 +0000)
to zero terminate the principal strings.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2397 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/bld_pr_ext.c

index ca2697335ba23a2be582d0588288c90431bcc5b6..625d9697fa109004a954fc946d543360b5a232ca 100644 (file)
@@ -83,7 +83,7 @@ va_dcl
     }
     princ_ret->data = princ_data;
     princ_ret->length = count;
-    tmpdata = malloc(rlen);
+    tmpdata = malloc(rlen+1);
     if (!tmpdata) {
        xfree(princ_data);
        xfree(princ_ret);
@@ -92,6 +92,7 @@ va_dcl
     krb5_princ_set_realm_length(princ_ret, rlen);
     krb5_princ_set_realm_data(princ_ret, tmpdata);
     memcpy(tmpdata, realm, rlen);
+    tmpdata[rlen] = 0;
 
     /* process rest of components */
 #if __STDC__ || defined(STDARG_PROTOTYPES)
@@ -103,13 +104,15 @@ va_dcl
        size = va_arg(ap, int);
        next = va_arg(ap, char *);
        princ_data[i].length = size;
-       princ_data[i].data = malloc(size);
+       princ_data[i].data = malloc(size+1);
        if (!princ_data[i].data)
            goto free_out;
        memcpy(princ_data[i].data, next, size);
+       princ_data[i].data[size] = 0;
     }
     va_end(ap);
     *princ = princ_ret;
+    krb5_princ_type(princ_ret) = KRB5_NT_UNKNOWN;
     return 0;
 
 free_out: