From: Gerhard Sittig Date: Sat, 21 Jul 2018 20:30:05 +0000 (+0200) Subject: input/vcd: abort VCD import when timestamp counts backwards X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ed367d68203593224af3c9593cfef0662b56007c;p=libsigrok.git input/vcd: abort VCD import when timestamp counts backwards The VCD specification requests that timestamps will strictly increase as one advances through the file. Add another check where the previous implementation resulted in a tight loop and made the application stall. Do print an error message and abort file processing in that case. This fixes bug #1250. --- diff --git a/src/input/vcd.c b/src/input/vcd.c index 7614ba68..b9e9497d 100644 --- a/src/input/vcd.c +++ b/src/input/vcd.c @@ -408,6 +408,10 @@ static void parse_contents(const struct sr_input *in, char *data) inc->prev_timestamp = inc->skip; } else if (timestamp == inc->prev_timestamp) { /* Ignore repeated timestamps (e.g. sigrok outputs these) */ + } else if (timestamp < inc->prev_timestamp) { + sr_err("Invalid timestamp: %" PRIu64 " (smaller than previous timestamp).", timestamp); + inc->skip_until_end = TRUE; + break; } else { if (inc->compress != 0 && timestamp - inc->prev_timestamp > inc->compress) { /* Compress long idle periods */