]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
uuidd: use snprintf() rather than sprintf()
authorKarel Zak <kzak@redhat.com>
Tue, 27 Jul 2021 11:30:42 +0000 (13:30 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 27 Jul 2021 11:30:42 +0000 (13:30 +0200)
misc-utils/uuidd.c

index fa8db173bedbfcead707be9f6cc2de4381acde98..f8b595ea7bef1664551364f8db2039a52a9821ab 100644 (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: