ubik: Avoid use of freed string
authorMarc Dionne <marc.dionne@your-file-system.com>
Thu, 9 May 2013 16:30:39 +0000 (12:30 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 10 May 2013 19:00:44 +0000 (12:00 -0700)
If cellName was just set to dir->cellName, afsconf_Close() will
free the string before fprintf uses it.  Just change the order
so we don't access freed memory and print garbage.

Change-Id: I66792dc50addf2d8242f71923db09fcc178cc450
Reviewed-on: http://gerrit.openafs.org/9886
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

src/ubik/uinit.c

index ca83acc..a61a029 100644 (file)
@@ -143,10 +143,10 @@ internal_client_init_dir(const char *confDir, char *cellName, int secFlags,
 
     code = afsconf_GetCellInfo(dir, cellName, serviceid, &info);
     if (code) {
-       afsconf_Close(dir);
        fprintf(stderr, "%s: can't find cell %s's hosts in %s/%s\n",
                progname?progname:"<unknown>", cellName, confDir,
                AFSDIR_CELLSERVDB_FILE);
+       afsconf_Close(dir);
        return code;
     }