Skip to contentSkip to conversation

hw/wm8750: Fix potential buffer overflow

PATCH Applied Stefan Weil 3 participants 3 messages Sep 3, 2012 – Sep 10, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/wm8750: Fix potential buffer overflow

Report from smatch:

hw/wm8750.c:369 wm8750_tx(12) error: buffer overflow 's->i2c_data' 2 <= 2

It looks like the preprocessor statements were simply misplaced.

Replace also __FUNCTION__ by __func__ to please checkpatch.pl.

---
 hw/wm8750.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/wm8750.c +2 -2
index 11bcec3..44f138f 100644
@@ -361,10 +361,10 @@ static int wm8750_tx(I2CSlave *i2c, uint8_t data)
     uint16_t value;
 
     if (s->i2c_len >= 2) {
-        printf("%s: long message (%i bytes)\n", __FUNCTION__, s->i2c_len);
 #ifdef VERBOSE
-        return 1;
+        printf("%s: long message (%i bytes)\n", __func__, s->i2c_len);
 #endif
+        return 1;
     }
     s->i2c_data[s->i2c_len ++] = data;
     if (s->i2c_len != 2)
Signature · 1 line
1.7.10
#2 lore raw
In reply to Stefan Weil
Quoted 33 lines · Stefan Weil

Report from smatch:

hw/wm8750.c:369 wm8750_tx(12) error: buffer overflow 's->i2c_data' 2 <= 2

It looks like the preprocessor statements were simply misplaced.

Replace also __FUNCTION__ by __func__ to please checkpatch.pl.

---
 hw/wm8750.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/wm8750.c +2 -2
index 11bcec3..44f138f 100644
@@ -361,10 +361,10 @@ static int wm8750_tx(I2CSlave *i2c, uint8_t data)
     uint16_t value;
 
     if (s->i2c_len >= 2) {
-        printf("%s: long message (%i bytes)\n", __FUNCTION__, s->i2c_len);
 #ifdef VERBOSE
-        return 1;
+        printf("%s: long message (%i bytes)\n", __func__, s->i2c_len);
 #endif
+        return 1;
     }
     s->i2c_data[s->i2c_len ++] = data;
     if (s->i2c_len != 2)
Signature · 1 line
1.7.10

Thanks, applied.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net