Ver código fonte

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
Rongjing Liao 5 anos atrás
pai
commit
2905808346
1 arquivos alterados com 5 adições e 0 exclusões
  1. 5 0
      target_if/spectral/target_if_spectral_phyerr.c

+ 5 - 0
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));
 	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++) {
 	for (i = 0; i < _len; i++) {
 		mod = i % SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE;
 		mod = i % SPECTRAL_HEXDUMP_NUM_OCTETS_PER_LINE;