]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
kill: port to picky-conversion hosts
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 18 Sep 2022 02:41:15 +0000 (19:41 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 18 Sep 2022 02:41:31 +0000 (19:41 -0700)
* src/kill.c (send_signals): Don’t rely on conversion overflow
being silent.

src/kill.c

index be01b2bf4c12da7e5af1290694f16f33c10d5f5c..33e602dcdca7a7ada6c346a0e32eb64076fad66c 100644 (file)
@@ -199,9 +199,10 @@ send_signals (int signum, char *const *argv)
     {
       char *endp;
       intmax_t n = (errno = 0, strtoimax (arg, &endp, 10));
-      pid_t pid = n;
+      pid_t pid;
 
-      if (errno == ERANGE || pid != n || arg == endp || *endp)
+      if (errno == ERANGE || INT_ADD_WRAPV (n, 0, &pid)
+          || arg == endp || *endp)
         {
           error (0, 0, _("%s: invalid process id"), quote (arg));
           status = EXIT_FAILURE;