public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: Florian Weimer <fw@deneb.enyo.de>,
	Alejandro Colomar via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH 1/2] Implement strlcpy and strlcat [BZ #178]
Date: Fri, 7 Apr 2023 00:15:48 +0200	[thread overview]
Message-ID: <39634c36-975a-b065-24db-2c23cbbb8754@gmail.com> (raw)
In-Reply-To: <87fs9cn171.fsf@mid.deneb.enyo.de>


[-- Attachment #1.1: Type: text/plain, Size: 1887 bytes --]

Hi Florian,

On 4/6/23 23:35, Florian Weimer wrote:
[...]

> 
> OpenBSD alludes to this as well:
> 
> | strlcat() appends string src to the end of dst. It will append at
> | most dstsize - strlen(dst) - 1 characters. It will then
> | NUL-terminate, unless dstsize is 0 or the original dst string was
> | longer than dstsize (in practice this should not happen as it means
> | that either dstsize is incorrect or that dst is not a proper
> | string).

Hmm, that text replaced the one I quoted (which has been kept in
libbsd's page), in this commit:


commit 5df0f979487d1950d0e8885be683158e55ff4ae3
Author: deraadt <deraadt@openbsd.org>
Date:   Mon Apr 2 17:33:11 2012 +0000

    simplify the strlcpy/strlcat manual page substantially.  do less
    explaining of "what a C string is", and make it more clear that these
    functiosn BEHAVE EXACTLY LIKE snprintf with "%s"!  (anyone who wants
    to write a 'strlcpy considered harmful' paper should probably write a
    'strlcpy and snprintf considered harmful' paper instead).
    
    note to those from other projects reading this commit message: It would
    be very good if this new manual was picked up in your project.
    
    ok jmc millert krw

> 
> <https://man.openbsd.org/strlcat>
> 
> So I think we should be calling strnlen here.  If we call strlen
> instead, we'd have to bound the result.

Hmm, it depends on what we decide to do with the conditional right
after the strnlen(3) call.  Either we remove the conditional, or
transform strnlen(3) to strlen(3), but not both.  I guess strnlen(3)
is more readable, since it's just one line.

Anyway, as I said, I would just burn it all and make this function
be a two-liner.  :)

Cheers,
Alex

> 
> Thanks,
> Florian

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-04-06 22:15 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-05 11:20 [PATCH 0/2] strlcpy/strlcat/wcslcpy/wcscat implementation Florian Weimer
2023-04-05 11:20 ` [PATCH 1/2] Implement strlcpy and strlcat [BZ #178] Florian Weimer
2023-04-05 13:18   ` Adhemerval Zanella Netto
2023-04-06  9:18     ` Florian Weimer
2023-04-06 14:22   ` Siddhesh Poyarekar
2023-04-06 15:09     ` Florian Weimer
2023-04-06 21:29     ` Alejandro Colomar
2023-04-11 14:28       ` Siddhesh Poyarekar
2023-04-20 10:55     ` Florian Weimer
2023-04-20 11:45       ` Siddhesh Poyarekar
2023-04-21 17:45         ` Florian Weimer
2023-04-06 21:21   ` Alejandro Colomar
2023-04-06 21:35     ` Florian Weimer
2023-04-06 22:15       ` Alejandro Colomar [this message]
2023-04-06 22:19       ` Alejandro Colomar
2023-04-06 22:34     ` Alejandro Colomar
2023-04-08 22:08   ` Paul Eggert
2023-04-09 15:29     ` Paul Eggert
2023-04-13 11:37       ` Florian Weimer
2023-04-13 14:39         ` Paul Eggert
2023-04-13 17:59           ` Paul Eggert
2023-04-20  8:07     ` Florian Weimer
2023-04-21 19:00       ` Paul Eggert
2023-04-28  8:49         ` Florian Weimer
2023-04-05 11:20 ` [PATCH 2/2] Add the wcslcpy, wcslcat functions Florian Weimer
2023-04-08 22:09   ` Paul Eggert
2023-04-05 12:30 ` [PATCH 0/2] strlcpy/strlcat/wcslcpy/wcscat implementation Alejandro Colomar
2023-04-08 22:05 ` Paul Eggert

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=39634c36-975a-b065-24db-2c23cbbb8754@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=fw@deneb.enyo.de \
    --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).