confile_utils: convert to strnprintf()

parent 18105e58
...@@ -753,18 +753,17 @@ bool new_hwaddr(char *hwaddr) ...@@ -753,18 +753,17 @@ bool new_hwaddr(char *hwaddr)
seed = randseed(false); 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); rand_r(&seed) % 255, rand_r(&seed) % 255);
#else #else
(void)randseed(true); (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); rand() % 255, rand() % 255);
#endif #endif
if (ret < 0 || ret >= 18) { if (ret < 0)
return log_error_errno(false, EIO, "Failed to call snprintf()"); return log_error_errno(false, EIO, "Failed to call strnprintf()");
}
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment