]> sigrok.org Git - libsigrok.git/commitdiff
input/vcd: abort VCD import when timestamp counts backwards
authorGerhard Sittig <redacted>
Sat, 21 Jul 2018 20:30:05 +0000 (22:30 +0200)
committerUwe Hermann <redacted>
Sun, 22 Jul 2018 14:15:26 +0000 (16:15 +0200)
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.

src/input/vcd.c

index 7614ba68a6f7bc192dab8c4f85cddccb91c34954..b9e9497dc8baf07b65370329179a615d2c175531 100644 (file)
@@ -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 */