bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'strlcpy'


From: Bruno Haible
Subject: Re: new module 'strlcpy'
Date: Thu, 28 Sep 2017 02:44:53 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-93-generic; KDE/5.18.0; x86_64; ; )

I wrote:
>    In some places the users
>    will notice that strlcpy does not buy them much, compared to the
>    "avoid arbitrary limits"[1] approach, and will switch over to what
>    you call "GNU style". In other places, they will insert an abort()
>    or assert() to handle the truncation case - which is *better* than
>    the strncpy approach.

For example, in gnulib's setlocale.c override. This file has fixed-size
buffers and silent truncation - because it uses the "strncpy and set NUL byte"
approach. As soon as someone (me) will use strlcpy with __warn_unused_result__
there, he will change the code to do
  - either dynamic allocation and no arbitrary limits,
  - or provide a good alternative to the silent truncation.
Either result will be better than the current one.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]