]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
procfs-util: use xsprintf() where appropriate
authorMike Yuan <me@yhndnzj.com>
Mon, 24 Mar 2025 15:35:46 +0000 (16:35 +0100)
committerMike Yuan <me@yhndnzj.com>
Fri, 4 Apr 2025 13:34:51 +0000 (15:34 +0200)
src/basic/procfs-util.c

index d7cfcd9105bf4ed27b964fe9295b4f035c48ac33..060ea7adad8d5f95e6bca9d0c3971fe5e668c2d3 100644 (file)
@@ -62,13 +62,13 @@ int procfs_tasks_set_limit(uint64_t limit) {
         /* As pid_max is about the numeric pid_t range we'll bump it if necessary, but only ever increase it, never
          * decrease it, as threads-max is the much more relevant sysctl. */
         if (limit > pid_max-1) {
-                sprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */
+                xsprintf(buffer, "%" PRIu64, limit+1); /* Add one, since PID 0 is not a valid PID */
                 r = write_string_file("/proc/sys/kernel/pid_max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER);
                 if (r < 0)
                         return r;
         }
 
-        sprintf(buffer, "%" PRIu64, limit);
+        xsprintf(buffer, "%" PRIu64, limit);
         r = write_string_file("/proc/sys/kernel/threads-max", buffer, WRITE_STRING_FILE_DISABLE_BUFFER);
         if (r < 0) {
                 uint64_t threads_max;