From 7071588516dc99f6e4a0e2f79dd15b0f50c9b1d5 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Tue, 1 May 1990 14:23:44 +0000 Subject: [PATCH] rearrange code to eliminate null-deref problem git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@636 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/parse.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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; -- 2.26.2