openwrtv4/package/network/services/dnsmasq/patches/0012-Sane-error-message-when-pcap-file-header-is-wrong.patch

26 lines
1,006 B
Diff
Raw Normal View History

From cc5cc8f1e0b4deaaea4cbefe677989b186c84837 Mon Sep 17 00:00:00 2001
From: Simon Kelley <simon@thekelleys.org.uk>
Date: Sat, 2 Jun 2018 14:45:17 +0100
Subject: [PATCH 12/17] Sane error message when pcap file header is wrong.
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
---
src/dump.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/src/dump.c
+++ b/src/dump.c
@@ -64,9 +64,10 @@ void dump_init(void)
die(_("cannot create %s: %s"), daemon->dump_file, EC_FILE);
}
else if ((daemon->dumpfd = open(daemon->dump_file, O_APPEND | O_RDWR)) == -1 ||
- !read_write(daemon->dumpfd, (void *)&header, sizeof(header), 1) ||
- header.magic_number != 0xa1b2c3d4)
+ !read_write(daemon->dumpfd, (void *)&header, sizeof(header), 1))
die(_("cannot access %s: %s"), daemon->dump_file, EC_FILE);
+ else if (header.magic_number != 0xa1b2c3d4)
+ die(_("bad header in %s"), daemon->dump_file, EC_FILE);
else
{
/* count existing records */