From: Julien Grall <julien@xen.org>
To: Jan Beulich <jbeulich@suse.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Ian Jackson <iwj@xenproject.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>
Subject: Re: [PATCH] rangeset: no need to use snprintf()
Date: Tue, 6 Apr 2021 14:44:01 +0100 [thread overview]
Message-ID: <80d625d8-6812-7d02-c946-a3905cbc306d@xen.org> (raw)
In-Reply-To: <2338703b-3613-41c6-8ae6-387ba2869408@suse.com>
Hi Jan,
On 06/04/2021 09:50, Jan Beulich wrote:
> As of the conversion to safe_strcpy() years ago there has been no need
> anymore to use snprintf() to prevent storing a not-nul-terminated string.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
>
> --- a/xen/common/rangeset.c
> +++ b/xen/common/rangeset.c
> @@ -436,14 +436,7 @@ struct rangeset *rangeset_new(
> BUG_ON(flags & ~RANGESETF_prettyprint_hex);
> r->flags = flags;
>
> - if ( name != NULL )
> - {
> - safe_strcpy(r->name, name);
> - }
> - else
> - {
> - snprintf(r->name, sizeof(r->name), "(no name)");
> - }
> + safe_strcpy(r->name, name ?: "(no name)");
I realize the current code is not checking the return, but I wonder we
should rather than silently truncating the string.
This is not a new issue, so it can dealt separately if we decide to
check the return.
Cheers,
--
Julien Grall
next prev parent reply other threads:[~2021-04-06 13:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 8:50 [PATCH] rangeset: no need to use snprintf() Jan Beulich
2021-04-06 13:44 ` Julien Grall [this message]
2021-04-06 13:56 ` Jan Beulich
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=80d625d8-6812-7d02-c946-a3905cbc306d@xen.org \
--to=julien@xen.org \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=jbeulich@suse.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.