Skip to contentSkip to conversation

staging: gpib: avoid buffer overflow

PATCH Dave Penkler 1 participant 1 message Oct 17, 2024 1 message not in the archive Staging

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Kees,

Quoted 23 lines · Kees Bakker

The remaining buffer size for snprintf also depends on pos.

---
 drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gpib/ni_usb/ni_usb_gpib.c +1 -1
index 1da263676f2a..4df1ceaa138f 100644
@@ -364,7 +364,7 @@ static void ni_usb_dump_raw_block(const u8 *raw_data, int length)
 			pr_info("%s\n", print_buf);
 			pos = 0;
 		}
-		pos += snprintf(&print_buf[pos], RAW_BUF_SIZE, " %02x", raw_data[i]);
+		pos += snprintf(&print_buf[pos], RAW_BUF_SIZE - pos, " %02x", raw_data[i]);
 	}
 	if (pos)
 		pr_info("%s\n", print_buf);
Signature · 1 line
2.47.0

Thanks.
Please copy the <[email protected]> mailing list. Can you do this also for agilent_82357a.c
-Dave