Re: [PATCH 30/32] strlen.3, wcslen.3: Add recommendations for safer variants

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

 



Hi Alex,

On 8/8/21 3:24 AM, Alejandro Colomar (man-pages) wrote:
> Hi Michael,
> 
> On 8/8/21 3:20 AM, Michael Kerrisk (man-pages) wrote:
>>> I have some doubts about this patch, but in a completely different sense:
>>>
>>> I don't know if I'm being a bit paranoid in treating user input.  I've
>>> always been taught that I should program deffensively, but as time
>>> passes by, I realize myself that I was programming too much
>>> deffensively, and even introducing bugs in the error handling code.  And
>>> in many cases, strings will always be NUL-terminated, so maybe I'm just
>>> passing around a wrong recommendation.
>>>
>>> What do you think about this?
>>
>> How about a sentence something like:
>>
>> [[
>> In cases where the input buffer may not contain a terminating null byte,
>> .BR strnlen (3)
>> should be used instead.
>> ]]
>>
>> What do you think?
> 
> Yes, that's much better.  Thanks!

Okay. I applied the patch below.

Thanks,

Michael

diff --git a/man3/strlen.3 b/man3/strlen.3
index dea4c1050..ca7a7d188 100644
--- a/man3/strlen.3
+++ b/man3/strlen.3
@@ -64,6 +64,11 @@ T}   Thread safety   MT-Safe
 .hy
 .ad
 .sp 1
+.SH NOTES
+In cases where the input buffer may not contain
+a terminating null byte,
+.BR strnlen (3)
+should be used instead.
 .SH CONFORMING TO
 POSIX.1-2001, POSIX.1-2008, C89, C99, C11, SVr4, 4.3BSD.
 .SH SEE ALSO
diff --git a/man3/wcslen.3 b/man3/wcslen.3
index af3fcb9ca..24dca8e55 100644
--- a/man3/wcslen.3
+++ b/man3/wcslen.3
@@ -56,6 +56,11 @@ T}   Thread safety   MT-Safe
 .hy
 .ad
 .sp 1
+.SH NOTES
+In cases where the input buffer may not contain
+a terminating null wide character,
+.BR wcsnlen (3)
+should be used instead.
 .SH CONFORMING TO
 POSIX.1-2001, POSIX.1-2008, C99.
 .SH SEE ALSO



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux