summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Economos <w6rz@comcast.net>2019-02-25 21:50:07 -0800
committerAndrej Rode <mail@andrejro.de>2019-03-04 11:37:17 +0100
commitb773a4d8f65aa264e0c342a62d55457bc2c6fcba (patch)
treed59e3123ee283cc0201c12c64be0dd951a84560b
parent0ab1a75a8181e2d89d82b499913d5e30b2bca018 (diff)
dtv: Prevent out of bounds array access in DVB-T2 interleaver.
-rw-r--r--gr-dtv/lib/dvbt2/dvbt2_interleaver_bb_impl.cc24
-rw-r--r--gr-dtv/lib/dvbt2/dvbt2_interleaver_bb_impl.h4
2 files changed, 17 insertions, 11 deletions
diff --git a/gr-dtv/lib/dvbt2/dvbt2_interleaver_bb_impl.cc b/gr-dtv/lib/dvbt2/dvbt2_interleaver_bb_impl.cc
index a0d5fc447b..6dc49bff7a 100644
--- a/gr-dtv/lib/dvbt2/dvbt2_interleaver_bb_impl.cc
+++ b/gr-dtv/lib/dvbt2/dvbt2_interleaver_bb_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2015,2016,2018 Free Software Foundation, Inc.
+ * Copyright 2015,2016,2018,2019 Free Software Foundation, Inc.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -164,10 +164,10 @@ namespace gr {
}
inline void
- dvbt2_interleaver_bb_impl::twist_interleave_columns(int* tempv, int* tempu, int rows, const int *twist)
+ dvbt2_interleaver_bb_impl::twist_interleave_columns(int* tempv, int* tempu, int rows, int mod, const int *twist)
{
int index = 0, offset;
- for (int col = 0; col < (mod * 2); col++) {
+ for (int col = 0; col < mod; col++) {
offset = twist[col];
for (int row = 0; row < rows; row++) {
tempv[offset + (rows * col)] = tempu[index++];
@@ -183,12 +183,15 @@ namespace gr {
dvbt2_interleaver_bb_impl::generate_lookup()
{
int rows, index = 0;
- int tempv[FRAME_SIZE_NORMAL];
- int tempu[FRAME_SIZE_NORMAL];
+ int *tempv;
+ int *tempu;
const int *twist;
const int *c1, *c2, *c3, *c4, *c5, *c6, *c7, *c8;
const int *c9, *c10, *c11, *c12, *c13, *c14, *c15, *c16;
+ tempv = new int[FRAME_SIZE_NORMAL];
+ tempu = new int[FRAME_SIZE_NORMAL];
+
for(int i = 0; i < FRAME_SIZE_NORMAL; i++) {
lookup_table[i] = i;
}
@@ -218,7 +221,7 @@ namespace gr {
c7 = &tempv[rows * 6];
c8 = &tempv[rows * 7];
- twist_interleave_columns(tempv, tempu, rows, twist);
+ twist_interleave_columns(tempv, tempu, rows, mod * 2, twist);
for (int j = 0; j < rows; j++) {
tempu[index++] = c1[j];
@@ -257,7 +260,7 @@ namespace gr {
c11 = &tempv[rows * 10];
c12 = &tempv[rows * 11];
- twist_interleave_columns(tempv, tempu, rows, twist);
+ twist_interleave_columns(tempv, tempu, rows, mod * 2, twist);
for (int j = 0; j < rows; j++) {
tempu[index++] = c1[j];
@@ -298,7 +301,7 @@ namespace gr {
c15 = &tempv[rows * 14];
c16 = &tempv[rows * 15];
- twist_interleave_columns(tempv, tempu, rows, twist256n);
+ twist_interleave_columns(tempv, tempu, rows, mod * 2, twist256n);
for (int j = 0; j < rows; j++) {
tempu[index++] = c1[j];
@@ -333,7 +336,7 @@ namespace gr {
c7 = &tempv[rows * 6];
c8 = &tempv[rows * 7];
- twist_interleave_columns(tempv, tempu, rows, twist256s);
+ twist_interleave_columns(tempv, tempu, rows, mod, twist256s);
for (int j = 0; j < rows; j++) {
tempu[index++] = c1[j];
@@ -350,6 +353,9 @@ namespace gr {
//tempu now has the input indices interleaved correctly, so save it
memcpy(lookup_table, tempu, frame_size * sizeof(int));
+
+ delete[] tempu;
+ delete[] tempv;
}
/*
diff --git a/gr-dtv/lib/dvbt2/dvbt2_interleaver_bb_impl.h b/gr-dtv/lib/dvbt2/dvbt2_interleaver_bb_impl.h
index ef6098d4a3..7218464d5e 100644
--- a/gr-dtv/lib/dvbt2/dvbt2_interleaver_bb_impl.h
+++ b/gr-dtv/lib/dvbt2/dvbt2_interleaver_bb_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2015 Free Software Foundation, Inc.
+ * Copyright 2015,2018,2019 Free Software Foundation, Inc.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ namespace gr {
void generate_lookup();
inline void interleave_parity_bits(int *tempu, const int *&in);
- inline void twist_interleave_columns(int* tempv, int* tempu, int rows, const int *twist);
+ inline void twist_interleave_columns(int* tempv, int* tempu, int rows, int mod, const int *twist);
const static int twist16n[8];
const static int twist64n[12];