usb-redir: fix stack overflow in usbredir_log_data
PATCH 1/1 usb-redir: fix stack overflow in usbredir_log_data
Don't reinvent a broken wheel, just use the hexdump function we have.
Impact: low, broken code doesn't run unless you have debug logging enabled.
Reported-by 李强 <[email protected]>
Signed-off-by Gerd Hoffmann <[email protected]>
--- hw/usb/redirect.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
hw/usb/redirect.c +1 -12
@@ -229,21 +229,10 @@ static void usbredir_log(void *priv, int level, const char *msg)static void usbredir_log_data (USBRedirDevice *dev,const char *desc,const uint8_t *data,int len) { -int i, j, n; -if (dev->debug < usbredirparser_debug_data) {return ; } - -for (i =0 ; i < len; i += j) { -char buf[128 ]; - - n =sprintf (buf,"%s" , desc); -for (j =0 ; j <8 && i + j < len; j++) { - n +=sprintf (buf + n," %02X" , data[i + j]); - } -error_report ("%s" , buf); - } +qemu_hexdump ((char *)data, stderr, desc, len); }/*
Signature · 1 line
2.9.3
Shouldn't we be checking if a monitor has been set instead of printing to stderr anyway?
Quoted 43 lines · Gerd Hoffmann
Don't reinvent a broken wheel, just use the hexdump function we have.
Impact: low, broken code doesn't run unless you have debug logging enabled.
Reported-by 李强 <[email protected]>Signed-off-by Gerd Hoffmann <[email protected]>---
hw/usb/redirect.c| 13 +------------1 file changed, 1 insertion(+), 12 deletions(-)hw/usb/redirect.c +1
-12@@ -229,21 +229,10 @@ static void usbredir_log(void *priv, int level, const char *msg)static void usbredir_log_data (USBRedirDevice *dev,const char *desc,const uint8_t *data,int len) { -int i, j, n; -if (dev->debug < usbredirparser_debug_data) {return ; } - -for (i =0 ; i < len; i += j) { -char buf[128 ]; - - n =sprintf (buf,"%s" , desc); -for (j =0 ; j <8 && i + j < len; j++) { - n +=sprintf (buf + n," %02X" , data[i + j]); - } -error_report ("%s" , buf); - } +qemu_hexdump ((char *)data, stderr, desc, len); }/* Signature · 1 line
2.9.3