summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-12-27 21:28:48 +0000
committerrwatson <rwatson@FreeBSD.org>2007-12-27 21:28:48 +0000
commit60c8c67e863493001d80ba3072f29bc710e10c29 (patch)
tree12f8fb8cd3b7a777713a2413ec0be55073bd2abe /sbin
parentd9b244638ead855a1ff6847b1f72eec87015d416 (diff)
downloadFreeBSD-src-60c8c67e863493001d80ba3072f29bc710e10c29.zip
FreeBSD-src-60c8c67e863493001d80ba3072f29bc710e10c29.tar.gz
Compare kernel dump header magic with textdump magic using strncmp()
rather than the memcmp() which is used for regular dumps: the textdump string is one character shorter, so we need to stop comparing at the end of the string. Use independent version checking logic for architecture-specific version number vs. textdump version number, as the version sequences may (someday) differ. Run into by: rrs
Diffstat (limited to 'sbin')
-rw-r--r--sbin/savecore/savecore.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index 72448a3..7763648 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -419,12 +419,32 @@ DoFile(const char *savedir, const char *device)
goto closefd;
}
istextdump = 0;
- if (memcmp(kdhl.magic, TEXTDUMPMAGIC, sizeof kdhl.magic)) {
+ if (strncmp(kdhl.magic, TEXTDUMPMAGIC, sizeof kdhl) == 0) {
if (verbose)
printf("textdump magic on last dump header on %s\n",
device);
istextdump = 1;
- } else if (memcmp(kdhl.magic, KERNELDUMPMAGIC, sizeof kdhl.magic)) {
+ if (dtoh32(kdhl.version) != KERNELDUMP_TEXT_VERSION) {
+ syslog(LOG_ERR,
+ "unknown version (%d) in last dump header on %s",
+ dtoh32(kdhl.version), device);
+
+ status = STATUS_BAD;
+ if (force == 0)
+ goto closefd;
+ }
+ } else if (memcmp(kdhl.magic, KERNELDUMPMAGIC, sizeof kdhl.magic) ==
+ 0) {
+ if (dtoh32(kdhl.version) != KERNELDUMPVERSION) {
+ syslog(LOG_ERR,
+ "unknown version (%d) in last dump header on %s",
+ dtoh32(kdhl.version), device);
+
+ status = STATUS_BAD;
+ if (force == 0)
+ goto closefd;
+ }
+ } else {
if (verbose)
printf("magic mismatch on last dump header on %s\n",
device);
@@ -443,15 +463,15 @@ DoFile(const char *savedir, const char *device)
syslog(LOG_ERR, "unable to force dump - bad magic");
goto closefd;
}
- }
- if (dtoh32(kdhl.version) != KERNELDUMPVERSION) {
- syslog(LOG_ERR,
- "unknown version (%d) in last dump header on %s",
- dtoh32(kdhl.version), device);
-
- status = STATUS_BAD;
- if (force == 0)
- goto closefd;
+ if (dtoh32(kdhl.version) != KERNELDUMPVERSION) {
+ syslog(LOG_ERR,
+ "unknown version (%d) in last dump header on %s",
+ dtoh32(kdhl.version), device);
+
+ status = STATUS_BAD;
+ if (force == 0)
+ goto closefd;
+ }
}
nfound++;
OpenPOWER on IntegriCloud