uuidd: use snprintf() rather than sprintf()

This commit is contained in:
Karel Zak 2021-07-27 13:30:42 +02:00
parent 2605d88379
commit 948cac89f3

View file

@ -395,7 +395,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
create_daemon();
if (pidfile_path) {
sprintf(reply_buf, "%8d\n", getpid());
snprintf(reply_buf, sizeof(reply_buf), "%8d\n", getpid());
if (ftruncate(fd_pidfile, 0))
err(EXIT_FAILURE, _("could not truncate file: %s"), pidfile_path);
write_all(fd_pidfile, reply_buf, strlen(reply_buf));
@ -485,11 +485,11 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
switch (op) {
case UUIDD_OP_GETPID:
sprintf(reply_buf, "%d", getpid());
snprintf(reply_buf, sizeof(reply_buf), "%d", getpid());
reply_len = strlen(reply_buf) + 1;
break;
case UUIDD_OP_GET_MAXOP:
sprintf(reply_buf, "%d", UUIDD_MAX_OP);
snprintf(reply_buf, sizeof(reply_buf), "%d", UUIDD_MAX_OP);
reply_len = strlen(reply_buf) + 1;
break;
case UUIDD_OP_TIME_UUID: