svn rev #22169: trunk/src/lib/krb5/os/

ghudson@MIT.EDU ghudson at MIT.EDU
Fri Apr 3 14:14:40 EDT 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=22169
Commit By: ghudson
Log Message:
Adjust the logic in rule_an_to_ln to avoid a "can't happen" case of
strchr returning null when searching for a character we know is there.
Also properly return ENOMEM if we fail to allocate selstring.



Changed Files:
U   trunk/src/lib/krb5/os/an_to_ln.c
Modified: trunk/src/lib/krb5/os/an_to_ln.c
===================================================================
--- trunk/src/lib/krb5/os/an_to_ln.c	2009-04-03 05:36:25 UTC (rev 22168)
+++ trunk/src/lib/krb5/os/an_to_ln.c	2009-04-03 18:14:40 UTC (rev 22169)
@@ -488,7 +488,7 @@
     char		*current;
     char		*fprincname;
     char		*selstring = 0;
-    int			num_comps, compind;
+    int			num_comps, compind, pos;
     size_t selstring_used;
     char		*cout;
     krb5_const krb5_data *datap;
@@ -503,16 +503,16 @@
 	 * First part.
 	 */
 	if (*current == '[') {
-	    if (sscanf(current+1,"%d:", &num_comps) == 1) {
+	    current++;
+	    if (sscanf(current,"%d:%n", &num_comps, &pos) == 1) {
 		if (num_comps == aname->length) {
 		    /*
 		     * We have a match based on the number of components.
 		     */
-		    current = strchr(current, ':');
+		    current += pos;
 		    selstring = (char *) malloc(MAX_FORMAT_BUFFER);
 		    selstring_used = 0;
-		    if (current && selstring) {
-			current++;
+		    if (selstring) {
 			cout = selstring;
 			/*
 			 * Plow through the string.
@@ -572,6 +572,8 @@
 			errout: if (kret)
 			    free(selstring);
 		    }
+		    else
+			kret = ENOMEM;
 		}
 		else
 		    kret = KRB5_LNAME_NOTRANS;




More information about the cvs-krb5 mailing list