From 29058083462e2530a3bae5114ebcafbd1d2d2632 Mon Sep 17 00:00:00 2001 From: Rongjing Liao Date: Tue, 17 Mar 2020 16:30:46 +0800 Subject: [PATCH] qcacmn: add argument '_len' sanity check before use When argument '_len' is equal to 0 or less than 0, 'ascii' array element will be used uninitialized. To fix this case, add arguemnt sanity check before use. Change-Id: I2e2a4c199fac72466f831bb4261a6a03ac116e11 CRs-Fixed: 2643354 --- target_if/spectral/target_if_spectral_phyerr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target_if/spectral/target_if_spectral_phyerr.c b/target_if/spectral/target_if_spectral_phyerr.c index 9bde5a893d..a928e40f8e 100644 --- a/target_if/spectral/target_if_spectral_phyerr.c +++ b/target_if/spectral/target_if_spectral_phyerr.c @@ -75,6 +75,11 @@ static inline void target_if_spectral_hexdump(unsigned char *_buf, int _len) qdf_mem_zero(hexdump_line, sizeof(hexdump_line)); + if (_len <= 0) { + spectral_err("buffer len is %d, too short", _len); + return; + } + for (i = 0; i < _len; i++) { mod = i % SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE;