supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Leah Neukirchen <leah@vuxu.org>
To: supervision@list.skarnet.org
Subject: [PATCH] chpst: fix parsing of negative values in -n
Date: Sun, 11 Dec 2022 18:53:31 +0100	[thread overview]
Message-ID: <875yehrfms.fsf@vuxu.org> (raw)

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/

             reply	other threads:[~2022-12-11 17:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-11 17:53 Leah Neukirchen [this message]
2022-12-13 23:28 ` Lorenzo via supervision

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yehrfms.fsf@vuxu.org \
    --to=leah@vuxu.org \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).