Skip to contentSkip to conversation

net: make iov_to_buf take right size argument in nc_sendv_compat()

PATCH In review Yang Hongyang 3 participants 4 messages Oct 20, 2015 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 net: make iov_to_buf take right size argument in nc_sendv_compat()

We want "buf, sizeof(buf)" here. sizeof(buffer) is the size of a pointer, which is wrong.
Thanks to Paolo for pointing it out.

Cc Jason Wang <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 net/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/net.c +1 -1
index 39af893..0c4a012 100644
@@ -700,7 +700,7 @@ static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov,
         offset = iov[0].iov_len;
     } else {
         buffer = buf;
-        offset = iov_to_buf(iov, iovcnt, 0, buffer, sizeof(buffer));
+        offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf));
     }
 
     if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) {
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 net: free the string returned by object_get_canonical_path_component

The value returned from object_get_canonical_path_component must be freed.

Cc Jason Wang <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 net/net.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/net.c +3 -2
index 0c4a012..459bf19 100644
@@ -1189,10 +1189,11 @@ void print_net_client(Monitor *mon, NetClientState *nc)
         monitor_printf(mon, "filters:\n");
     }
     QTAILQ_FOREACH(nf, &nc->filters, next) {
-        monitor_printf(mon, "  - %s: type=%s%s\n",
-                       object_get_canonical_path_component(OBJECT(nf)),
+        char *path = object_get_canonical_path_component(OBJECT(nf));
+        monitor_printf(mon, "  - %s: type=%s%s\n", path,
                        object_get_typename(OBJECT(nf)),
                        nf->info_str);
+        g_free(path);
     }
 }
 
Signature · 1 line
1.9.1
#2 lore raw
In reply to Yang Hongyang
Quoted 16 lines · Yang Hongyang

We want "buf, sizeof(buf)" here. sizeof(buffer) is the size of a pointer, which is wrong.
Thanks to Paolo for pointing it out.

Cc Jason Wang <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 net/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/net.c +0 -0
index 39af893..0c4a012 100644

net/net.c static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, · line 706

Quoted 8 lines
net/net.c +1 -1
@@ -700,7 +700,7 @@ static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov,
         offset = iov[0].iov_len;
     } else {
         buffer = buf;
-        offset = iov_to_buf(iov, iovcnt, 0, buffer, sizeof(buffer));
+        offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf));
     }
 
     if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) {

Both two patches were applied in:

https://github.com/jasowang/qemu/commits/net

Thanks

#3 lore raw
Quoted 26 lines · Jason Wang
Quoted 23 lines · Yang Hongyang

We want "buf, sizeof(buf)" here. sizeof(buffer) is the size of a pointer, which is wrong.
Thanks to Paolo for pointing it out.

Cc Jason Wang <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 net/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/net.c +1 -1
index 39af893..0c4a012 100644
@@ -700,7 +700,7 @@ static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov,
         offset = iov[0].iov_len;
     } else {
         buffer = buf;
-        offset = iov_to_buf(iov, iovcnt, 0, buffer, sizeof(buffer));
+        offset = iov_to_buf(iov, iovcnt, 0, buf, sizeof(buf));
     }
 
Quoted 7 lines

net/net.c static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, · line 706

Quoted 1 line
net/net.c +0 -0
     if (flags & QEMU_NET_PACKET_FLAG_RAW && nc->info->receive_raw) {

Both two patches were applied in:

https://github.com/jasowang/qemu/commits/net

Thanks

Thanks!

Paolo