summary refs log tree commit diff stats
path: root/net/tap.c
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2021-04-02 11:03:33 +0800
committerJason Wang <jasowang@redhat.com>2021-04-08 17:33:59 +0800
commit56e6f594bf47a0a543ff5e6d14701355fe99b098 (patch)
tree0b3ee5f7b43fde16795a00537796a87f0289d020 /net/tap.c
parent603f2f7c6c8c747d0189936a74fb33e610ce7858 (diff)
downloadfocaccia-qemu-56e6f594bf47a0a543ff5e6d14701355fe99b098.tar.gz
focaccia-qemu-56e6f594bf47a0a543ff5e6d14701355fe99b098.zip
Revert "net: Move NetClientState.info_str to dynamic allocations"
Several issues has been reported for query-netdev info
series. Consider it's late in the rc, this reverts commit
commit 59b5437eb732d6b103a9bc279c3482c834d1eff9.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'net/tap.c')
-rw-r--r--net/tap.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/net/tap.c b/net/tap.c
index 522ce7e487..35895192c5 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -635,7 +635,8 @@ int net_init_bridge(const Netdev *netdev, const char *name,
         stored->helper = g_strdup(helper);
     }
 
-    s->nc.info_str = g_strdup_printf("helper=%s,br=%s", helper, br);
+    snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s,br=%s", helper,
+             br);
 
     return 0;
 }
@@ -723,7 +724,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
             g_free(tmp_s);
         }
 
-        s->nc.info_str = g_strdup_printf("fd=%d", fd);
+        snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=%d", fd);
     } else if (tap->has_helper) {
         if (!stored->has_helper) {
             stored->has_helper = true;
@@ -736,7 +737,8 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
                                        g_strdup(DEFAULT_BRIDGE_INTERFACE);
         }
 
-        s->nc.info_str = g_strdup_printf("helper=%s", tap->helper);
+        snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s",
+                 tap->helper);
     } else {
         if (ifname && !stored->has_ifname) {
             stored->has_ifname = true;
@@ -753,8 +755,9 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
             stored->downscript = g_strdup(downscript);
         }
 
-        s->nc.info_str = g_strdup_printf("ifname=%s,script=%s,downscript=%s",
-                                         ifname, script, downscript);
+        snprintf(s->nc.info_str, sizeof(s->nc.info_str),
+                 "ifname=%s,script=%s,downscript=%s", ifname, script,
+                 downscript);
 
         if (strcmp(downscript, "no") != 0) {
             snprintf(s->down_script, sizeof(s->down_script), "%s", downscript);