]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
rlimit-util: use read_full_file() for /proc/PID/limits
authorMike Yuan <me@yhndnzj.com>
Thu, 13 Mar 2025 17:04:52 +0000 (18:04 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 1 May 2025 04:10:26 +0000 (13:10 +0900)
This one uses "seq_file", i.e. normal FILE stream just works.

src/basic/rlimit-util.c

index 5dc8b56a07a24a3d7b6045e210db46a75775dd8b..0032f23c2646a92968da7844faab7952e7ba4f33 100644 (file)
@@ -471,12 +471,12 @@ int pid_getrlimit(pid_t pid, int resource, struct rlimit *ret) {
         const char *p = procfs_file_alloca(pid, "limits");
         _cleanup_free_ char *limits = NULL;
 
-        r = read_full_virtual_file(p, &limits, NULL);
+        r = read_full_file(p, &limits, /* ret_size = */ NULL);
         if (r < 0)
                 return -EPERM; /* propagate original permission error if we can't access the limits file */
 
         _cleanup_strv_free_ char **l = NULL;
-        l = strv_split(limits, "\n");
+        l = strv_split_newlines(limits);
         if (!l)
                 return -ENOMEM;