]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libsystemd-network: use xsprintf in one more place
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 10 Jan 2019 15:13:06 +0000 (16:13 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 16 Jan 2019 12:34:31 +0000 (13:34 +0100)
DECIMAL_STR_MAX includes space for NUL, so we don't need 2 here.

src/libsystemd-network/dhcp-identifier.c

index 07496adaa390f06555810d0cfb8ea5121b13c1c5..4221b9c5044e1b8e7dd949d03df4ae4a5171b342 100644 (file)
@@ -11,6 +11,7 @@
 #include "network-internal.h"
 #include "siphash24.h"
 #include "sparse-endian.h"
+#include "stdio-util.h"
 #include "virt.h"
 
 #define SYSTEMD_PEN    43793
@@ -169,10 +170,10 @@ int dhcp_identifier_set_iaid(
 
         if (detect_container() <= 0) {
                 /* not in a container, udev will be around */
-                char ifindex_str[2 + DECIMAL_STR_MAX(int)];
+                char ifindex_str[1 + DECIMAL_STR_MAX(int)];
                 int r;
 
-                sprintf(ifindex_str, "n%d", ifindex);
+                xsprintf(ifindex_str, "n%d", ifindex);
                 if (sd_device_new_from_device_id(&device, ifindex_str) >= 0) {
                         r = sd_device_get_is_initialized(device);
                         if (r < 0)