From d8fa251a14e9469fb6ec722d100b6a8557248694 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Tue, 26 Feb 2013 12:21:59 +0000 Subject: [PATCH] ubik: Zero header before writing to disk The ubik disk header contains a padding field, which is never zeroed before being written out to disk. This means that there is a shorts worth of stack garbage in every ubik label! Just zero the whole structure with memset before we populate it. Caught by coverity (#986011) Change-Id: Ib9f8b45111a83178372409c717c30ccb6a1044f4 Reviewed-on: http://gerrit.openafs.org/9272 Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Derrick Brashear Tested-by: BuildBot --- src/ubik/phys.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ubik/phys.c b/src/ubik/phys.c index b8fbef4eb..4ce6a226d 100644 --- a/src/ubik/phys.c +++ b/src/ubik/phys.c @@ -274,6 +274,9 @@ uphys_setlabel(struct ubik_dbase *adbase, afs_int32 afile, fd = uphys_open(adbase, afile); if (fd < 0) return UNOENT; + + memset(&thdr, 0, sizeof(thdr)); + thdr.version.epoch = htonl(aversion->epoch); thdr.version.counter = htonl(aversion->counter); thdr.magic = htonl(UBIK_MAGIC); -- 2.39.5