aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/services/dnsmasq/patches/0012-Sane-error-message-when-pcap-file-header-is-wrong.patch
blob: fb2d2d7a4a94bda9ecc91a44701e9d8bedc6bba9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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 */