From 44e806431bec3149a78127f5d1003e84e3a0b072 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Wed, 27 Feb 2013 10:34:59 +0000 Subject: [PATCH] ubik: Avoid unlinking garbage If SDISK_SendFail fails before the pathname to the temporary file has been constructed, then the failure handler will unlink stack garbage, with variable results. Initialise the string, and check to see if it has contents before calling unlink Change-Id: I1de898d5f0f0dc608e9c9c62dc66e6b4b9fdc5bf Reviewed-on: http://gerrit.openafs.org/9299 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/ubik/remote.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ubik/remote.c b/src/ubik/remote.c index 44917e2ac..37d938411 100644 --- a/src/ubik/remote.c +++ b/src/ubik/remote.c @@ -455,6 +455,7 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file, /* send the file back to the requester */ dbase = ubik_dbase; + pbuffer[0] = '\0'; if ((code = ubik_CheckAuth(rxcall))) { DBHOLD(dbase); @@ -576,7 +577,9 @@ failed_locked: failed: if (code) { - unlink(pbuffer); + if (pbuffer[0] != '\0') + unlink(pbuffer); + /* Failed to sync. Allow reads again for now. */ if (dbase != NULL) { UBIK_VERSION_LOCK; -- 2.39.5