This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v7] Implement strlcpy, strlcat [BZ #178]

On 2016-01-06 00:05, Paul Eggert wrote:
On 01/05/2016 11:14 AM, Alexander Cherepanov wrote:
Your first reading of POSIX seems quite reasonable to me. And that
reading conflicts with C11 so I reported it in .

I was referring to the C11 semantics,

Ok. Then perhaps you are willing to remove the following piece from the snprintf description: "you should allocate at least @var{size} characters for the string @var{s}"[1]? (And maybe fix the use of xmalloc/xrealloc vs. results checks in the example there.)

More generally, the glibc manual describes many functions quite differently from C11 (e.g., I've filed bugs 19406 and 19407) and it's not clear what are the plans in this area.


which POSIX defers to. In looking
at that bug-report trail, it appears that the semantics of snprintf are
controversial in this area. And rightly so, since C11 requires
implementations to not diagnose troublesome application usage such as
snprintf (buf, SIZE_MAX, ...).

Some call it troublesome, others consider SIZE_MAX a useful no-truncation-required value permitting to unify various code paths.

it boils down to the question which sources are considers
authoritative for describing strlcpy/strlcat?

There aren't any. The BSD man pages do not agree, and their
implementations do not agree. If we add strlcpy/strlcat, we will just
need to use our best judgment to distinguish valid from buggy uses.

Ok, I see.

Alexander Cherepanov

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]