Skip to contentSkip to conversation

qemu-sockets: Fix buffer overflow in inet_parse()

PATCH Applied Kevin Wolf 3 participants 3 messages Jan 30, 2015 – Feb 7, 2015

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 qemu-sockets: Fix buffer overflow in inet_parse()

The size of the stack allocated host[] array didn't account for the terminating '\0' byte that sscanf() writes. Fix the array size.

---
 util/qemu-sockets.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/qemu-sockets.c +1 -1
index a76bb3c..aacf1fc 100644
@@ -512,7 +512,7 @@ InetSocketAddress *inet_parse(const char *str, Error **errp)
 {
     InetSocketAddress *addr;
     const char *optstr, *h;
-    char host[64];
+    char host[65];
     char port[33];
     int to;
     int pos;
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Kevin Wolf

The size of the stack allocated host[] array didn't account for the terminating '\0' byte that sscanf() writes. Fix the array size.

---
  util/qemu-sockets.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
util/qemu-sockets.c +0 -0
index a76bb3c..aacf1fc 100644

util/qemu-sockets.c InetSocketAddress *inet_parse(const char *str, Error **errp) · line 518

Quoted 8 lines
util/qemu-sockets.c +1 -1
@@ -512,7 +512,7 @@ InetSocketAddress *inet_parse(const char *str, Error **errp)
  {
      InetSocketAddress *addr;
      const char *optstr, *h;
-    char host[64];
+    char host[65];
      char port[33];
      int to;
      int pos;

You don't really need reviews for trivial, right?
*shrug*

#2 lore raw
In reply to Kevin Wolf
Quoted 2 lines · Kevin Wolf

The size of the stack allocated host[] array didn't account for the terminating '\0' byte that sscanf() writes. Fix the array size.

Applied to -trivial, thank you!

/mjt