[25740] in CVS-changelog-for-Kerberos-V5
svn rev #25230: trunk/src/lib/kdb/
daemon@ATHENA.MIT.EDU (ghudson@mit.edu)
Sat Sep 24 08:19:23 2011
Date: Sat, 24 Sep 2011 08:19:21 -0400
From: ghudson@mit.edu
Message-Id: <201109241219.p8OCJL72024768@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu
http://src.mit.edu/fisheye/changelog/krb5/?cs=25230
Commit By: ghudson
Log Message:
Fix krb5_dbe_get_strings error handling.
The old error handling was incorrect in the case where a strdup() call
returns NULL but realloc() returns non-NULL.
Changed Files:
U trunk/src/lib/kdb/kdb5.c
Modified: trunk/src/lib/kdb/kdb5.c
===================================================================
--- trunk/src/lib/kdb/kdb5.c 2011-09-24 12:19:14 UTC (rev 25229)
+++ trunk/src/lib/kdb/kdb5.c 2011-09-24 12:19:21 UTC (rev 25230)
@@ -2048,16 +2048,14 @@
while (next_attr(&pos, end, &mapkey, &mapval)) {
/* Add a copy of mapkey and mapvalue to strings. */
+ newstrings = realloc(strings, (count + 1) * sizeof(*strings));
+ if (newstrings == NULL)
+ goto oom;
+ strings = newstrings;
key = strdup(mapkey);
val = strdup(mapval);
- newstrings = realloc(strings, (count + 1) * sizeof(*strings));
- if (key == NULL || val == NULL || newstrings == NULL) {
- free(key);
- free(val);
- krb5_dbe_free_strings(context, strings, count);
- return ENOMEM;
- }
- strings = newstrings;
+ if (key == NULL || val == NULL)
+ goto oom;
strings[count].key = key;
strings[count].value = val;
count++;
@@ -2066,6 +2064,12 @@
*strings_out = strings;
*count_out = count;
return 0;
+
+oom:
+ free(key);
+ free(val);
+ krb5_dbe_free_strings(context, strings, count);
+ return ENOMEM;
}
krb5_error_code
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5