From: John Kohl Date: Tue, 1 May 1990 14:23:44 +0000 (+0000) Subject: rearrange code to eliminate null-deref problem X-Git-Tag: krb5-1.0-alpha2~760 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7071588516dc99f6e4a0e2f79dd15b0f50c9b1d5;p=krb5.git rearrange code to eliminate null-deref problem git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@636 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/krb/parse.c b/src/lib/krb5/krb/parse.c index 37b149c6f..f7131809e 100644 --- a/src/lib/krb5/krb/parse.c +++ b/src/lib/krb5/krb/parse.c @@ -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;