diff --git a/src/terminal/typescript.c b/src/terminal/typescript.c index 3b8790b1..2460cadb 100644 --- a/src/terminal/typescript.c +++ b/src/terminal/typescript.c @@ -98,13 +98,15 @@ void guac_terminal_typescript_flush(guac_terminal_typescript* typescript) { guac_timestamp this_flush = guac_timestamp_current(); guac_timestamp last_flush = typescript->last_flush; - /* Calculate elapsed time in seconds */ - double elapsed_time = (this_flush - last_flush) / 1000.0; + /* Calculate time since last flush */ + int elapsed_time = this_flush - last_flush; + if (elapsed_time > GUAC_TERMINAL_TYPESCRIPT_MAX_DELAY) + elapsed_time = GUAC_TERMINAL_TYPESCRIPT_MAX_DELAY; /* Produce single line of timestamp output */ char timestamp_buffer[32]; int timestamp_length = snprintf(timestamp_buffer, sizeof(timestamp_buffer), - "%0.6f %i\n", elapsed_time, typescript->length); + "%0.6f %i\n", elapsed_time / 1000.0, typescript->length); /* Calculate actual length of timestamp line */ if (timestamp_length > sizeof(timestamp_buffer)) diff --git a/src/terminal/typescript.h b/src/terminal/typescript.h index 172a71c8..b6bba80f 100644 --- a/src/terminal/typescript.h +++ b/src/terminal/typescript.h @@ -40,6 +40,13 @@ */ #define GUAC_TERMINAL_TYPESCRIPT_FOOTER "\n[END TYPESCRIPT]\n" +/** + * The maximum amount of time to allow for a particular timing entry, in + * milliseconds. Any timing entries exceeding this value will be written as + * exactly this value instead. + */ +#define GUAC_TERMINAL_TYPESCRIPT_MAX_DELAY 86400000 + /** * An active typescript, consisting of a data file (raw terminal output) and * timing file (related timestamps and byte counts).