From: Jan Beulich <jbeulich@suse.com>
To: Julien Grall <julien@xen.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>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] rangeset: no need to use snprintf()
Date: Tue, 6 Apr 2021 15:56:09 +0200 [thread overview]
Message-ID: <060c0a6a-128e-2c44-fe51-59dadbc1c5f6@suse.com> (raw)
In-Reply-To: <80d625d8-6812-7d02-c946-a3905cbc306d@xen.org>
On 06.04.2021 15:44, Julien Grall wrote:
> 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>
Thanks.
>> --- 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.
The name field is used only for display purposes, so I guess truncation
wouldn't really be a problem here.
Jan
prev parent reply other threads:[~2021-04-06 13:56 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
2021-04-06 13:56 ` Jan Beulich [this message]
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=060c0a6a-128e-2c44-fe51-59dadbc1c5f6@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=julien@xen.org \
--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.