From 4bfbd754ea70a6ab99a45c1170e1ada582e78b83 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Tue, 7 May 2019 22:16:40 -0500 Subject: [PATCH] hmmst'd've --- examples/Makefile | 2 +- src/pcapng.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index e2dd50a..cb2a172 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -8,7 +8,7 @@ CFLAGS += -I$(INCLUDE_PATH) LDFLAGS = -L../src -lhexagram STATIC = ../src/libhexagram.a -EXAMPLES = duration view +EXAMPLES = view RM = /bin/rm diff --git a/src/pcapng.c b/src/pcapng.c index 8f83b88..1b77e67 100644 --- a/src/pcapng.c +++ b/src/pcapng.c @@ -22,6 +22,7 @@ ssize_t hexagram_pcapng_read_options(hexagram_pcapng_stream *stream, while (total < len) { ssize_t readlen; + size_t remaining; if ((readlen = read(stream->fd, &option, sizeof(option))) < 0) { stream->error = HEXAGRAM_PCAPNG_ERROR_IO; @@ -41,8 +42,8 @@ ssize_t hexagram_pcapng_read_options(hexagram_pcapng_stream *stream, total += readlen; } - if (option.length % sizeof(uint32_t)) { - size_t padding = sizeof(uint32_t) - (option.length % sizeof(uint32_t)); + if ((remaining = option.length % sizeof(uint32_t)) > 0) { + size_t padding = sizeof(uint32_t) - remaining; if ((readlen = lseek(stream->fd, padding, SEEK_CUR)) < 0) { goto error_io;