From: Andrew Deason Date: Fri, 23 Oct 2009 20:02:12 +0000 (-0500) Subject: Avoid 'salvageserver -client -showlog' segfault X-Git-Tag: openafs-devel-1_5_67~109 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=b90f4241285efccdf8be5f9ce3ae28c64fbccd38;p=packages%2Fo%2Fopenafs.git Avoid 'salvageserver -client -showlog' segfault Running salvageserver with the -client and -showlog options will currently segfault, since -client does not open logFile, and -showlog will attempt to rewind logFile on exit. Fix this by not allowing -client and -showlog together (since it won't work anyway, as -showlog tries to read SalvageLog), and by making showlog() check logFile for NULL-ness. Change-Id: I30f43ef1696f1e7e8873b9e1cc3867b4e06d1980 Reviewed-on: http://gerrit.openafs.org/734 Tested-by: Andrew Deason Tested-by: Derrick Brashear Reviewed-by: Derrick Brashear --- diff --git a/src/vol/salvaged.c b/src/vol/salvaged.c index 2a79027b5..6094f1e27 100644 --- a/src/vol/salvaged.c +++ b/src/vol/salvaged.c @@ -274,6 +274,11 @@ handleit(struct cmd_syndesc *as, void *arock) vid = atoi(ti->data); } + if (ShowLog) { + printf("-showlog does not work with -client\n"); + exit(-1); + } + if (!seenpart || !seenvol) { printf("You must specify '-partition' and '-volumeid' with the '-client' option\n"); exit(-1); diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index f66ae82be..e5daf80fb 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -3563,8 +3563,10 @@ showlog(void) } #endif - rewind(logFile); - fclose(logFile); + if (logFile) { + rewind(logFile); + fclose(logFile); + } logFile = afs_fopen(AFSDIR_SERVER_SLVGLOG_FILEPATH, "r");