* [PATCH] chpst: fix parsing of negative values in -n
@ 2022-12-11 17:53 Leah Neukirchen
2022-12-13 23:28 ` Lorenzo via supervision
0 siblings, 1 reply; 2+ messages in thread
From: Leah Neukirchen @ 2022-12-11 17:53 UTC (permalink / raw)
To: supervision
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
@@ -308,7 +308,7 @@
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@vuxu.org> https://leahneukirchen.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-13 23:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-11 17:53 [PATCH] chpst: fix parsing of negative values in -n Leah Neukirchen
2022-12-13 23:28 ` Lorenzo via supervision
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).