From: Derrick Brashear Date: Thu, 19 Jul 2007 15:57:54 +0000 (+0000) Subject: STABLE14-vos-validate-dumpfile-20070719 X-Git-Tag: openafs-stable-1_4_5-pre1~53 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=6bc7d632d314b260c46b60804dbe5d41b4844ef5;p=packages%2Fo%2Fopenafs.git STABLE14-vos-validate-dumpfile-20070719 based on code from jon nials validate a dumpfile as being complete (look for end of dump signature) (cherry picked from commit 982f455debcb50d0a59b0997085e7b2e9475b604) --- diff --git a/src/volser/vos.c b/src/volser/vos.c index 73b0c7114..90ae55deb 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -57,7 +57,12 @@ RCSID #include #include "volser.h" #include "volint.h" +#include +#include +#include +#include "dump.h" #include "lockdata.h" + #ifdef AFS_AIX32_ENV #include #endif @@ -315,6 +320,9 @@ WriteData(struct rx_call *call, char *rock) long blksize; afs_int32 error, code; int ufdIsOpen = 0; + afs_hyper_t filesize, currOffset; + afs_uint32 buffer; + afs_uint32 got; error = 0; @@ -335,6 +343,20 @@ WriteData(struct rx_call *call, char *rock) goto wfail; } } + /* test if we have a valid dump */ + hset64(filesize, 0, 0); + USD_SEEK(ufd, filesize, SEEK_END, &currOffset); + hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32)); + USD_SEEK(ufd, filesize, SEEK_SET, &currOffset); + USD_READ(ufd, &buffer, sizeof(afs_uint32), &got); + if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) { + fprintf(STDERR, "Signature missing from end of file '%s'\n", filename); + error = VOLSERBADOP; + goto wfail; + } + hset64(filesize, 0, 0); + USD_SEEK(ufd, filesize, SEEK_SET, &currOffset); + /* rewind, we are done */ code = SendFile(ufd, call, blksize); if (code) { error = code;