[vlc-devel] [PATCH] opus: channel_mapping is in range 0-255

Pierre Lamot pierre at videolabs.io
Thu May 31 13:59:33 CEST 2018


  This patch fixes static analysis reports assuming that channel_mapping
  can have negative values (ie in opus ProcessInitialHeader). Opus channel
  mapping is in range 0-255

  fixes: CID 1062575 and 1062574
---
 modules/codec/opus_header.h | 2 +-
 modules/demux/mpeg/ts_psi.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/codec/opus_header.h b/modules/codec/opus_header.h
index 4b6a4e5d3c..b7f86e80b3 100644
--- a/modules/codec/opus_header.h
+++ b/modules/codec/opus_header.h
@@ -36,7 +36,7 @@ typedef struct {
     int preskip;
     uint32_t input_sample_rate;
     int gain; /* in dB S7.8 should be zero whenever possible */
-    int channel_mapping;
+    uint8_t channel_mapping;
     /* The rest is only used if channel_mapping != 0 */
     int nb_streams;
     int nb_coupled;
diff --git a/modules/demux/mpeg/ts_psi.c b/modules/demux/mpeg/ts_psi.c
index 17aefa2c4f..7fe2b09d95 100644
--- a/modules/demux/mpeg/ts_psi.c
+++ b/modules/demux/mpeg/ts_psi.c
@@ -948,7 +948,8 @@ static void OpusSetup(demux_t *demux, uint8_t *p, size_t len, es_format_t *p_fmt
     static const unsigned char map[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
     memcpy(h.stream_map, map, sizeof(map));
 
-    int csc, mapping;
+    uint8_t mapping;
+    int csc;
     int channels = 0;
     int stream_count = 0;
     int ccc = p[1]; // channel_config_code
-- 
2.14.1



More information about the vlc-devel mailing list