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