From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v2 3/3] manual: Manual update for strlcat, strlcpy, wcslcat, wclscpy
Date: Tue, 6 Jun 2023 08:42:47 -0400 [thread overview]
Message-ID: <4e29f176-ea9e-d913-2d36-f310ca5cab6e@gotplt.org> (raw)
In-Reply-To: <877csg93ni.fsf@oldenburg3.str.redhat.com>
On 2023-06-06 08:27, Florian Weimer wrote:
> * Siddhesh Poyarekar:
>
>>> +The behavior is undefined if @var{to} or @var{from} is a null pointer,
>>> +or if the destination array's size is less than @var{size}, or if the
>>> +string @var{from} overlaps the first @var{size} bytes of the
>>> +destination array.
>>
>> Shouldn't this be undefined for all kinds of overlaps between @var{to}
>> and @var{from} and not just when the @{from} overlaps with the first
>> @var{size} bytes of @var{to}?
>
> I don't think so. There is no reason why the data couldn't be copied
> within the same array. This can plausibly happen if a custom memory
> allocator is used, for example.
Uhmm, I haven't heard of the customer allocator argument being used in
this context but I suppose it makes sense. I'm probably just getting
jitters about specifying behaviour to that much detail when a simple
"behavior is undefined if FROM and TO overlap" would suffice. I mean
this argument could be made for memcpy or any function that assumes
non-aliased inputs.
>> Also, perhaps s/destination array/@var{to}/ to make it clearer.
>
> I don't think so because it's confusing whether the size refers to TO
> itself or (conceptually) to *TO.
Fair enough.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
next prev parent reply other threads:[~2023-06-06 12:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-20 12:28 [PATCH v2 0/3] strlcpy and related functions Florian Weimer
2023-04-20 12:28 ` [PATCH v2 1/3] Implement strlcpy and strlcat [BZ #178] Florian Weimer
2023-06-06 5:41 ` Siddhesh Poyarekar
2023-06-14 9:04 ` Florian Weimer
2023-04-20 12:28 ` [PATCH v2 2/3] Add the wcslcpy, wcslcat functions Florian Weimer
2023-06-06 5:56 ` Siddhesh Poyarekar
2023-04-20 12:28 ` [PATCH v2 3/3] manual: Manual update for strlcat, strlcpy, wcslcat, wclscpy Florian Weimer
2023-06-06 6:03 ` Siddhesh Poyarekar
2023-06-06 12:27 ` Florian Weimer
2023-06-06 12:42 ` Siddhesh Poyarekar [this message]
2023-04-20 16:19 ` [PATCH v2 0/3] strlcpy and related functions H.J. Lu
2023-04-21 17:46 ` Florian Weimer
2023-04-22 0:25 ` Noah Goldstein
2023-04-28 10:48 ` Florian Weimer
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=4e29f176-ea9e-d913-2d36-f310ca5cab6e@gotplt.org \
--to=siddhesh@gotplt.org \
--cc=fweimer@redhat.com \
--cc=libc-alpha@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).