]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Fix aklog segfault
authorBen Kaduk <kaduk@mit.edu>
Thu, 17 Jun 2010 04:27:51 +0000 (00:27 -0400)
committerDerrick Brashear <shadow@dementia.org>
Fri, 18 Jun 2010 03:06:08 +0000 (20:06 -0700)
In auth_to_cell(), we only strdup() into the linkedcell argument
if there is a linkedCell in the current cellconf.  However, in
main(), we free linkedcell if it is non-NULL, but it is allocated
on the stack and could contain garbage.  free() chokes on such
garbage, causing aklog to abort().
If we copy nothing into linkedcell, set it to NULL so that we
do not attempt to free the bogus pointer.

Change-Id: I92905a5f17021ce1bc41909f5ceb1b0344456d93
Reviewed-on: http://gerrit.openafs.org/2213
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Russ Allbery <rra@stanford.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/aklog/aklog.c

index 240854778ef49915f08d3843029e4f338a79982a..d3bb44c3d0ec74a3438cc48b939ec82fbf075549 100644 (file)
@@ -968,11 +968,15 @@ auth_to_cell(krb5_context context, char *cell, char *realm, char **linkedcell)
     if ((status = get_cellconfig(cell, &cellconf, &local_cell)))
        return(status);
 
-    if (linkedcell != NULL && cellconf.linkedCell != NULL) {
-       *linkedcell = strdup(cellconf.linkedCell);
-       if (*linkedcell == NULL) {
-           status = ENOMEM;
-           goto out;
+    if (linkedcell != NULL) {
+       if (cellconf.linkedCell != NULL) {
+           *linkedcell = strdup(cellconf.linkedCell);
+           if (*linkedcell == NULL) {
+               status = ENOMEM;
+               goto out;
+           }
+       } else {
+           *linkedcell = NULL;
        }
     }