rearrange code to eliminate null-deref problem
authorJohn Kohl <jtkohl@mit.edu>
Tue, 1 May 1990 14:23:44 +0000 (14:23 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Tue, 1 May 1990 14:23:44 +0000 (14:23 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@636 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/parse.c

index 37b149c6f3ac2b3bdc9305bf7457914aebe7a701..f7131809eb4a4f5cdba12150316f6013a721e0c6 100644 (file)
@@ -114,7 +114,7 @@ krb5_principal *principal;
     for (ncomponents = 1, cp = name,
         endcomponent = index(name, COMPONENT_SEP);
         cp && cp <= realmptr; 
-        ncomponents++, endcomponent = index(cp, COMPONENT_SEP)) {
+        ncomponents++) {
 
        if (endcomponent && endcomponent < realmptr) {
            retprinc[ncomponents]->length = endcomponent - cp;
@@ -135,9 +135,10 @@ krb5_principal *principal;
        strncpy(retprinc[ncomponents]->data, cp,
                retprinc[ncomponents]->length);
        retprinc[ncomponents]->data[retprinc[ncomponents]->length] = '\0';
-       if (endcomponent)
+       if (endcomponent) {
            cp = endcomponent + 1;      /* move past divider */
-       else
+           endcomponent = index(cp, COMPONENT_SEP);
+       } else
            cp = 0;
     }
     *principal = retprinc;