From: Corinna Vinschen <vinschen@redhat.com>
To: Matt Joyce <mfjoyce2004@gmail.com>
Cc: newlib@sourceware.org
Subject: Re: [PATCH 1/1] libc: Added implementation for sig2str/str2sig.
Date: Mon, 2 Aug 2021 13:48:04 +0200 [thread overview]
Message-ID: <YQfbdGjYhF7VqFdx@calimero.vinschen.de> (raw)
In-Reply-To: <20210731132205.536278-2-mfjoyce2004@gmail.com>
Hi Matt,
a collegue of mine pointed out that it might be good idea to be more
paranoid in terms of the output string size:
On Jul 31 15:22, Matt Joyce wrote:
> +sig2str(int signum, char *str)
> +{
> + const sig_name_and_num *sptr;
> +
> + /* If signum falls in lower half of the real time signals range, define
> + * the saved str value as "RTMIN+n" according to the Issue 8 standard */
> + if ((SIGRTMIN + 1) <= signum &&
> + signum <= (SIGRTMIN + SIGRTMAX) / 2) {
> + sprintf(str, "RTMIN+%d", (signum-SIGRTMIN));
snprintf(str, SIG2STR_MAX, "RTMIN+%d", (signum-SIGRTMIN));
> + return 0;
> + }
> +
> + /* If signum falls in upper half of the real time signals range, define
> + * the saved str value as "RTMAX-m" according to the Issue 8 standard */
> + if ((((SIGRTMIN + SIGRTMAX) / 2) + 1) <= signum &&
> + signum <= (SIGRTMAX - 1)) {
> + sprintf(str, "RTMAX-%d", (SIGRTMAX - signum));
snprintf(str, SIG2STR_MAX, "RTMAX+%d", (signum-SIGRTMIN));
> + return 0;
> + }
> +
> + /* Otherwise, search for signal matching signum in sig_array. If found,
> + * save its string value in str. */
> + for (sptr = sig_array; sptr < &sig_array[NUM_OF_SIGS]; sptr++) {
> + if (sptr->sig_num == signum) {
> + strcpy(str, sptr->sig_name);
strlcpy(str, sptr->sig_name, SIG2STR_MAX);
What do you think?
Corinna
next prev parent reply other threads:[~2021-08-02 11:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-31 13:22 [PATCH 0/1] V3: Implementation of sig2str/str2sig Matt Joyce
2021-07-31 13:22 ` [PATCH 1/1] libc: Added implementation for sig2str/str2sig Matt Joyce
2021-08-01 17:03 ` Joel Sherrill
2021-08-02 9:42 ` Corinna Vinschen
2021-08-02 11:48 ` Corinna Vinschen [this message]
2021-08-03 3:57 ` Matthew Joyce
2021-08-03 3:54 [PATCH 0/1] Final Edits to sig2str/str2sig Matt Joyce
2021-08-03 3:54 ` [PATCH 1/1] libc: Added implementation for sig2str/str2sig Matt Joyce
2021-08-03 7:44 ` Corinna Vinschen
2021-08-03 18:01 ` Matthew Joyce
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=YQfbdGjYhF7VqFdx@calimero.vinschen.de \
--to=vinschen@redhat.com \
--cc=mfjoyce2004@gmail.com \
--cc=newlib@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).