diff options
author | James Ko <jck@exegin.com> | 2018-09-28 12:02:42 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-09-28 20:59:17 +0000 |
commit | 91694e564075678897d611de3e25fd4571cfd80a (patch) | |
tree | c8a2ff30df7568ab90e8f6647aa0809e82adc102 /writecap | |
parent | 21ab1cf72a9756c44c71e5b8b26c65244e88b57b (diff) |
dumpcap: fix some warnings and add some debugs
Ping-Bug: 15149
Change-Id: Ifa530fbdcbffbc188343c03fc7b518325a511f5f
Reviewed-on: https://code.wireshark.org/review/29906
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'writecap')
-rw-r--r-- | writecap/pcapio.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/writecap/pcapio.c b/writecap/pcapio.c index e2094f681f..9e0d4689e6 100644 --- a/writecap/pcapio.c +++ b/writecap/pcapio.c @@ -280,7 +280,7 @@ pcapng_write_block(FILE* pfile, guint64 *bytes_written, int *err) { - guint32 block_length, end_lenth; + guint32 block_length, end_length; /* Check * - length and data are aligned to 4 bytes * - block_total_length field is the same at the start and end of the block @@ -290,11 +290,13 @@ pcapng_write_block(FILE* pfile, * us an implicit check of correctness without needing to do an endian swap */ if (((length & 3) != 0) || (((gintptr)data & 3) != 0)) { + *err = EINVAL; return FALSE; } - memcpy(&block_length, data+sizeof(guint32), sizeof(guint32)); - memcpy(&end_lenth, data+length-sizeof(guint32), sizeof(guint32)); - if (block_length != end_lenth) { + block_length = *(guint32 *) (data+sizeof(guint32)); + end_length = *(guint32 *) (data+length-sizeof(guint32)); + if (block_length != end_length) { + *err = EBADMSG; return FALSE; } return write_to_file(pfile, data, length, bytes_written, err); |