aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorStefan Weil via <qemu-devel@nongnu.org>2022-11-26 16:25:07 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2022-11-27 13:36:17 -0500
commitac149498215809bfb5c0ddce1953519fbfda5004 (patch)
tree713ff1144e702ba0059a7e81d6a586d429bd4646 /net
parentec09f22d01d1e59a42f0a5d4f02c325e03df3bc6 (diff)
downloadqemu-ac149498215809bfb5c0ddce1953519fbfda5004.zip
qemu-ac149498215809bfb5c0ddce1953519fbfda5004.tar.gz
qemu-ac149498215809bfb5c0ddce1953519fbfda5004.tar.bz2
Add G_GNUC_PRINTF to function qemu_set_info_str and fix related issues
With the G_GNUC_PRINTF function attribute the compiler detects two potential insecure format strings: ../../../net/stream.c:248:31: warning: format string is not a string literal (potentially insecure) [-Wformat-security] qemu_set_info_str(&s->nc, uri); ^~~ ../../../net/stream.c:322:31: warning: format string is not a string literal (potentially insecure) [-Wformat-security] qemu_set_info_str(&s->nc, uri); ^~~ There are also two other warnings: ../../../net/socket.c:182:35: warning: zero-length gnu_printf format string [-Wformat-zero-length] 182 | qemu_set_info_str(&s->nc, ""); | ^~ ../../../net/stream.c:170:35: warning: zero-length gnu_printf format string [-Wformat-zero-length] 170 | qemu_set_info_str(&s->nc, ""); Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20221126152507.283271-7-sw@weilnetz.de>
Diffstat (limited to 'net')
-rw-r--r--net/socket.c2
-rw-r--r--net/stream.c6
2 files changed, 4 insertions, 4 deletions
diff --git a/net/socket.c b/net/socket.c
index 4944bb7..e62137c 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -179,7 +179,7 @@ static void net_socket_send(void *opaque)
s->fd = -1;
net_socket_rs_init(&s->rs, net_socket_rs_finalize, false);
s->nc.link_down = true;
- qemu_set_info_str(&s->nc, "");
+ qemu_set_info_str(&s->nc, "%s", "");
return;
}
diff --git a/net/stream.c b/net/stream.c
index 53b7040..37ff727 100644
--- a/net/stream.c
+++ b/net/stream.c
@@ -167,7 +167,7 @@ static gboolean net_stream_send(QIOChannel *ioc,
net_socket_rs_init(&s->rs, net_stream_rs_finalize, false);
s->nc.link_down = true;
- qemu_set_info_str(&s->nc, "");
+ qemu_set_info_str(&s->nc, "%s", "");
qapi_event_send_netdev_stream_disconnected(s->nc.name);
@@ -245,7 +245,7 @@ static void net_stream_listen(QIONetListener *listener,
}
g_assert(addr != NULL);
uri = socket_uri(addr);
- qemu_set_info_str(&s->nc, uri);
+ qemu_set_info_str(&s->nc, "%s", uri);
g_free(uri);
qapi_event_send_netdev_stream_connected(s->nc.name, addr);
qapi_free_SocketAddress(addr);
@@ -319,7 +319,7 @@ static void net_stream_client_connected(QIOTask *task, gpointer opaque)
addr = qio_channel_socket_get_remote_address(sioc, NULL);
g_assert(addr != NULL);
uri = socket_uri(addr);
- qemu_set_info_str(&s->nc, uri);
+ qemu_set_info_str(&s->nc, "%s", uri);
g_free(uri);
ret = qemu_socket_try_set_nonblock(sioc->fd);