From b90f4241285efccdf8be5f9ce3ae28c64fbccd38 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 23 Oct 2009 15:02:12 -0500 Subject: [PATCH] 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 --- src/vol/salvaged.c | 5 +++++ src/vol/vol-salvage.c | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) 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"); -- 2.39.5