[PATCH] chpst: fix parsing of negative values in -n

From: Leah Neukirchen <leah_at_vuxu.org>
Date: Sun, 11 Dec 2022 18:53:31 +0100

I noticed chpst -n didn't work and found this fix. I just patched it
in Void, other distros may want to apply this too.

Fix UB which breaks -n with negative nice values.
Ensure optarg is incremented strictly before it is read from.

--- runit-2.1.2/src/chpst.c.orig
+++ runit-2.1.2/src/chpst.c
_at__at_ -308,7 +308,7 _at__at_
     case 'n':
       switch (*optarg) {
         case '-':
- if (optarg[scan_ulong(++optarg, &ul)]) usage(); nicelvl =ul;
+ ++optarg; if (optarg[scan_ulong(optarg, &ul)]) usage(); nicelvl =ul;
           nicelvl *=-1;
           break;
         case '+': ++optarg;

-- 
Leah Neukirchen  <leah_at_vuxu.org>  https://leahneukirchen.org/
Received on Sun Dec 11 2022 - 18:53:31 CET

This archive was generated by hypermail 2.4.0 : Sun Dec 11 2022 - 18:54:04 CET