From: Jaroslav Kysela Date: Fri, 17 Jun 2016 20:09:01 +0000 (+0200) Subject: dvbpsi: fix the dvb_desc_service() fcn - stack corruption (clang sanitizer) X-Git-Tag: v4.2.1~424 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71152399464d4b418d6f5de3b36937b077e1111c;p=thirdparty%2Ftvheadend.git dvbpsi: fix the dvb_desc_service() fcn - stack corruption (clang sanitizer) --- diff --git a/Makefile b/Makefile index b0aec405d..6bca28e48 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ LANGUAGES ?= bg cs da de en_US en_GB es et fa fi fr he hr hu it lv nl pl pt ru s # Common compiler flags # -CFLAGS += -g -O2 -fPIE +CFLAGS += -g -O0 -fPIE ifeq ($(CONFIG_PIE),yes) CFLAGS += -fPIE else diff --git a/src/input/mpegts/dvb_psi.c b/src/input/mpegts/dvb_psi.c index 5063ffe4c..28b1ecd42 100644 --- a/src/input/mpegts/dvb_psi.c +++ b/src/input/mpegts/dvb_psi.c @@ -418,14 +418,13 @@ dvb_desc_service /* Cleanup name */ str = sname; - while (*str && *str <= 32) + while (*str && *str <= ' ') str++; - memmove(sname, str, sname_len); // Note: could avoid this copy by passing an output ptr - l = strlen(str); - while (l > 1 && str[l-1] <= 32) { - str[l-1] = 0; - l--; - } + if (str != sname) + memmove(sname, str, sname_len - (str - sname)); + l = strlen(str); + while (l > 1 && str[l-1] <= ' ') + str[--l] = '\0'; return 0; }