]> git.proxmox.com Git - mirror_lxc.git/blobdiff - src/lxc/confile_utils.c
confile_utils: convert to strnprintf()
[mirror_lxc.git] / src / lxc / confile_utils.c
index b316de5f95ddfcbc61a6a20cd636674b9f2c4c57..f75d6ae00820c56775ec1df1e6ee1a35fb15a3b1 100644 (file)
@@ -768,18 +768,17 @@ bool new_hwaddr(char *hwaddr)
 
        seed = randseed(false);
 
-       ret = snprintf(hwaddr, 18, "00:16:3e:%02x:%02x:%02x", rand_r(&seed) % 255,
+       ret = strnprintf(hwaddr, 18, "00:16:3e:%02x:%02x:%02x", rand_r(&seed) % 255,
                       rand_r(&seed) % 255, rand_r(&seed) % 255);
 #else
 
        (void)randseed(true);
 
-       ret = snprintf(hwaddr, 18, "00:16:3e:%02x:%02x:%02x", rand() % 255,
+       ret = strnprintf(hwaddr, 18, "00:16:3e:%02x:%02x:%02x", rand() % 255,
                       rand() % 255, rand() % 255);
 #endif
-       if (ret < 0 || ret >= 18) {
-               return log_error_errno(false, EIO, "Failed to call snprintf()");
-       }
+       if (ret < 0)
+               return log_error_errno(false, EIO, "Failed to call strnprintf()");
 
        return true;
 }