ptserver: Zero ubik header before writing to it
authorSimon Wilkinson <sxw@your-file-system.com>
Tue, 26 Feb 2013 12:30:00 +0000 (12:30 +0000)
committerJeffrey Altman <jaltman@your-file-system.com>
Wed, 27 Feb 2013 01:19:40 +0000 (17:19 -0800)
When using pt_util's ubik shim, if we're creating a new ubik label
make sure to zero the whole structure before writing it out to disk.
Otherwise we get a shorts worth of stack garbage in the resulting
file.

Caught by coverity (#986010)

Change-Id: I0abb8b7968d4f25c97dc0927d63dd01099b829b7
Reviewed-on: http://gerrit.openafs.org/9274
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/ptserver/ptubik.c

index 6ca0eef..f059d2c 100644 (file)
@@ -33,6 +33,7 @@ ubik_BeginTrans(struct ubik_dbase *dbase, afs_int32 transMode,
     struct ubik_hdr thdr;
 
     if (!init) {
+       memset(&thdr, 0, sizeof(thdr));
        thdr.version.epoch = htonl(2);
        thdr.version.counter = htonl(0);
        thdr.magic = htonl(UBIK_MAGIC);