[vlc-devel] [PATCH 1/2] demux/playlist/dvb: prevent null-dereference on truncated lines

Filip Roséen filip at atch.se
Wed Mar 15 10:10:37 CET 2017


All three of ParseFec, ParseModulation, and Parseguard, are
potentially called with NULL (on unexpected (truncated) input), these
changes make sure that we do not dereference the passed pointer if
such happens.

Instead NULL is returned to signal that the parsing failed.

fixes: #18126
---
 modules/demux/playlist/dvb.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/demux/playlist/dvb.c b/modules/demux/playlist/dvb.c
index d5ef313564..72d07d3242 100644
--- a/modules/demux/playlist/dvb.c
+++ b/modules/demux/playlist/dvb.c
@@ -119,7 +119,7 @@ static const char *ParseFEC(const char *str)
          { "AUTO", "" },   { "NONE", "0" }
      };
 
-     if (strncmp(str, "FEC_", 4))
+     if (str == NULL || strncmp(str, "FEC_", 4))
          return NULL;
      str += 4;
 
@@ -143,6 +143,9 @@ static const char *ParseModulation(const char *str)
          { "VSB_16", "16VSB" }, { "VSB_8", "8VSB" }
      };
 
+     if( str == NULL )
+         return NULL;
+
      const struct mod *m = bsearch(str, tab, sizeof (tab) / sizeof(tab[0]),
                                    sizeof (tab[0]), cmp);
      return (m != NULL) ? m->vlc : NULL;
@@ -160,7 +163,7 @@ static const char *ParseGuard(const char *str)
          { "1_8", "1/8" }, { "AUTO", "" },
      };
 
-     if (strncmp(str, "GUARD_INTERVAL_", 15))
+     if (str == NULL || strncmp(str, "GUARD_INTERVAL_", 15))
          return NULL;
      str += 15;
 
-- 
2.12.0


More information about the vlc-devel mailing list