[dvblast-devel] [Git][videolan/dvblast][master] 3 commits: if hour, min or sec is >= 100 we can overflow duration_str
Georgi Chorbadzhiyski
georgi at unixsol.net
Tue Sep 15 08:21:03 CEST 2020
On 15.09.20 9:14, Georgi Chorbadzhiyski wrote:
> On 14.09.20 19:50, Christophe Massiot wrote:
>> Can your propose a fix?
>
> I guess something like the attached, a bigger buffer and snprintf.
..of course not compiling the damn thing is not a good idea :/
Fixed patch attached.
And patch to bitstream to fix compilation error.
-------------- next part --------------
>From 9a4a29de5083ef79de3c658c048954e2a177a280 Mon Sep 17 00:00:00 2001
From: Georgi Chorbadzhiyski <georgi at unixsol.org>
Date: Tue, 15 Sep 2020 09:04:02 +0300
Subject: [PATCH] Revert "if hour, min or sec is >= 100 we can overflow
duration_str"
This reimplements ff1e5700c032b156b950a668fa05362459177963 and fixes
a regression that the hour number was not zero padded.
---
dvblastctl.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/dvblastctl.c b/dvblastctl.c
index 9254b3d..7e255cd 100644
--- a/dvblastctl.c
+++ b/dvblastctl.c
@@ -217,31 +217,32 @@ void print_eit_events(uint8_t *p_eit, f_print pf_print, void *print_opaque, f_ic
uint8_t j = 0;
while ((p_event = eit_get_event(p_eit, j)) != NULL) {
j++;
- char start_str[24];
+ char start_str[24], duration_str[32];
int duration, hour, min, sec;
time_t start_ts;
start_ts = dvb_time_format_UTC(eitn_get_start_time(p_event), NULL, start_str);
dvb_time_decode_bcd(eitn_get_duration_bcd(p_event), &duration, &hour, &min, &sec);
+ snprintf(duration_str, sizeof(duration_str) - 1, "%02d:%02d:%02d", hour, min, sec);
switch (i_print_type) {
case PRINT_XML:
pf_print(print_opaque, "<EVENT id=\"%u\" start_time=\"%ld\" start_time_dec=\"%s\""
- " duration=\"%u\" duration_dec=\"%u:%02u:%02u\""
+ " duration=\"%u\" duration_dec=\"%s\""
" running=\"%d\" free_CA=\"%d\">",
eitn_get_event_id(p_event),
start_ts, start_str,
- duration, hour, min, sec,
+ duration, duration_str,
eitn_get_running(p_event),
eitn_get_ca(p_event)
);
break;
default:
- pf_print(print_opaque, " * EVENT id=%u start_time=%ld start_time_dec=\"%s\" duration=%u duration_dec=%u:%02u:%02u running=%d free_CA=%d",
+ pf_print(print_opaque, " * EVENT id=%u start_time=%ld start_time_dec=\"%s\" duration=%u duration_dec=%s running=%d free_CA=%d",
eitn_get_event_id(p_event),
start_ts, start_str,
- duration, hour, min, sec,
+ duration, duration_str,
eitn_get_running(p_event),
eitn_get_ca(p_event)
);
--
2.24.3 (Apple Git-128)
More information about the dvblast-devel
mailing list