Re: [RFC resend v1 2/2] Use arc4random_range() instead of arc4random_uniform() when appropriate

2023-01-02 Thread Alejandro Colomar
On 1/1/23 01:08, Alejandro Colomar wrote: On 12/31/22 20:08, Alejandro Colomar wrote: This makes the code much more readable and self-documented.  While doing this, I noticed a few bugs, and other cases which may be bugs or not. Switching to this specialized API makes it easier to spot such

Re: [RFC resend v1 2/2] Use arc4random_range() instead of arc4random_uniform() when appropriate

2022-12-31 Thread Alejandro Colomar
On 12/31/22 20:08, Alejandro Colomar wrote: This makes the code much more readable and self-documented. While doing this, I noticed a few bugs, and other cases which may be bugs or not. Switching to this specialized API makes it easier to spot such bugs, but since I'm not familiar wit

[RFC resend v1 2/2] Use arc4random_range() instead of arc4random_uniform() when appropriate

2022-12-31 Thread Alejandro Colomar
random_uniform(num2 - num3 + 1) + num3; + num1 = arc4random_range(num1, num2); Signed-off-by: Alejandro Colomar --- games/boggle/boggle/bog.c | 2 +- games/canfield/canfield/canfield.c | 2 +- games/mille/init.c

[RFC resend v1 1/2] Add arc4random_range(min, max)

2022-12-31 Thread Alejandro Colomar
Signed-off-by: Alejandro Colomar --- [resent, but to tech@, per Dave's advice] Hi, The patch to the manual page is still a draft; I know it has formatting issues; I don't know mdoc(7) enough to write in it. I CCd Ingo so that he may help me improve it. Theo, and any others, pleas

readpassphrase(3) in glibc, and agetpass() (Was: Is getpass(3) really obsolete?)

2022-09-27 Thread Alejandro Colomar
Hi Zack, On 10/29/21 16:53, Zack Weinberg via Libc-alpha wrote: On Fri, Oct 29, 2021, at 9:55 AM, Theo de Raadt wrote: wrote: On October 29, 2021 7:29 AM, Alejandro Colomar wrote: On 10/29/21 13:15, Alejandro Colomar wrote: Hi, As the manual pages says, SUSv2 marked it as LEGACY, and

Re: stpecpy(): A better string copy and concatenation function

2022-02-25 Thread Alejandro Colomar (man-pages)
Hello Ali, On 25/2/22 17:22, Ali Farzanrad wrote: "Alejandro Colomar (man-pages)" wrote: char dest[SIZE]; char *end; end = &dest[SIZE - 1]; stpecpy(dest, "Hello world", end); Perfect way to introduce new hidden bac

Re: stpecpy(): A better string copy and concatenation function

2022-02-13 Thread Alejandro Colomar (man-pages)
Hi Theo, On 2/13/22 23:45, Theo de Raadt wrote: > Your proposal isn't an improvement over the current situation with strl* > functions, and I don't think this is helpful. > > Alejandro Colomar (man-pages) wrote: >>Compared to other string copy and concatenation

stpecpy(): A better string copy and concatenation function

2022-02-13 Thread Alejandro Colomar (man-pages)
len == size) { len--; printf("Trunc: "); } printf("%ti: %s\n", len, buf); } SEE ALSO snprintf(3), strncat(3), strncpy(3), stpsecpy(3) alx2022-02-13 stpecpy(3) -- Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/

Re: Is getpass(3) really obsolete?

2021-10-30 Thread Alejandro Colomar (man-pages)
Hi Joseph, On 10/29/21 18:31, Joseph Myers wrote: On Fri, 29 Oct 2021, Alejandro Colomar (man-pages) via Libc-alpha wrote: The broader context is that I was trying to make the deprecation notices more consistent in the Linux manpages, by using the [[deprecated]] attribute where appropriate

[PATCH] getpass.3: SYNOPSIS: Mark getpass() as [[deprecated]]

2021-10-29 Thread Alejandro Colomar
n the past, and incorrectly led to readpassphrase(3). readpassphrase(3) has a few too many features/extensions for my taste, but at least it is harder to abuse. } Alejandro Colomar : { I found readpassphrase(3) in FreeBSD and OpenBSD. It is also present in libb

Re: Is getpass(3) really obsolete?

2021-10-29 Thread Alejandro Colomar (man-pages)
g for. What system are you on? <https://libbsd.freedesktop.org/wiki/> Cheers, Alex -- Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/

Re: Is getpass(3) really obsolete?

2021-10-29 Thread Alejandro Colomar (man-pages)
Hi Ævar, On 10/29/21 13:40, Ævar Arnfjörð Bjarmason wrote: On Fri, Oct 29 2021, Alejandro Colomar (man-pages) wrote: [Add a few CCs, since I mentioned them.] [I'm not sure what the full context of this thread is, but just replying from the POV of git@ being CC'd on this]

Re: Is getpass(3) really obsolete?

2021-10-29 Thread Alejandro Colomar (man-pages)
[Add a few CCs, since I mentioned them.] On 10/29/21 13:15, Alejandro Colomar wrote: Hi, As the manual pages says, SUSv2 marked it as LEGACY, and POSIX doesn't have it at all.  The manual page goes further and says "This function is obsolete. Do not use it." in its first line

Re: Possible bug in lib/libc/gen/exec.c

2021-09-16 Thread Alejandro Colomar (man-pages)
. -- Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/

Possible bug in lib/libc/gen/exec.c

2021-09-16 Thread Alejandro Colomar (man-pages)
macro, to avoid repetition. I can prepare a patch if you confirm the bug. Cheers, Alex -- Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/

Re: [RFC] strcpys(): New function for copying strings safely

2021-06-28 Thread Alejandro Colomar (man-pages)
On 6/28/21 1:32 PM, Alejandro Colomar (man-pages) wrote: The other use is where you want a sequence of: len *= str_copy(dest + len, dest_len - len, src); But don't really want to test for overflow after each call. This is a legitimate use of strscpy().  Please, add it to glibc, as

Re: [RFC] strcpys(): New function for copying strings safely

2021-06-28 Thread Alejandro Colomar (man-pages)
Hello David, On 6/28/21 10:15 AM, David Laight wrote: From: Alejandro Colomar Sent: 27 June 2021 20:47 On 6/27/21 9:26 PM, Alejandro Colomar (man-pages) wrote: It is designed so that usage requires the minimum number of lines of code for complete usage (including error handling checks

Re: [RFC] strcpys(): New function for copying strings safely

2021-06-27 Thread Alejandro Colomar (man-pages)
On 6/27/21 9:26 PM, Alejandro Colomar (man-pages) wrote: It is designed so that usage requires the minimum number of lines of code for complete usage (including error handling checks): [[ // When we already checked that 'size' is >= 1 // and truncation is not an issue: strcpys_

[RFC] strcpys(): New function for copying strings safely

2021-06-27 Thread Alejandro Colomar (man-pages)
but I expect it to be free of any bugs known of the existing str*cpy() interfaces. What do you think about this function? Would you want to add it to glibc? Thanks, Alex -- Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/

Re: [PATCH v3 (resend)] tee: Add -q, --quiet, --silent option to not write to stdout

2021-01-24 Thread Alejandro Colomar (man-pages)
On 1/24/21 5:11 PM, Teran McKinney wrote: > On 2021-01-24 13-18-46 , Alejandro Colomar wrote: >> This is useful for using tee to just write to a file, >> at the end of a pipeline, >> without having to redirect to /dev/null >> >> Example: >> >>

[PATCH v3 (resend)] tee: Add -q, --quiet, --silent option to not write to stdout

2021-01-24 Thread Alejandro Colomar
This is useful for using tee to just write to a file, at the end of a pipeline, without having to redirect to /dev/null Example: echo 'foo' | sudo tee -q /etc/foo; is equivalent to the old (and ugly) echo 'foo' | sudo tee /etc/foo >/dev/null; Signed-off-by: Alejandro

Re: [PATCH v2] tee: Add -q, --quiet, --silent option to not write to stdout

2021-01-23 Thread Alejandro Colomar (man-pages)
On 1/23/21 5:19 PM, Anders Damsgaard wrote: > (lots of Cc's removed) > > * Alejandro Colomar [2021-01-22 00:12:58 +0100]: > >> This is useful for using tee to just write to a file, >> at the end of a pipeline, >> without having to redirect to /dev/null. >

[PATCH] tee: Add -q, --quiet, --silent option to not write to stdout

2021-01-23 Thread Alejandro Colomar
This is useful for using tee to just write to a file, at the end of a pipeline, without having to redirect to /dev/null Example: echo 'foo' | sudo tee -q /etc/foo; is equivalent to the old (and ugly) echo 'foo' | sudo tee /etc/foo >/dev/null; --- v2: Add --silent synonym to --quiet, per GNU gu

Re: [PATCH v2] tee: Add -q, --quiet, --silent option to not write to stdout

2021-01-22 Thread Alejandro Colomar (man-pages)
I added a few FreeBSD CCs that I found on their tee.c's git blame, because the freebsd list rejects external mail. Please have a look at the proposal below, and the discussion that started on gnu coreutil's list. On 1/22/21 12:12 AM, Alejandro Colomar wrote: This is useful for us

[PATCH v2] tee: Add -q, --quiet, --silent option to not write to stdout

2021-01-21 Thread Alejandro Colomar
similar interface: grep Signed-off-by: Alejandro Colomar --- v2: Add --silent synonym to --quiet, per GNU guidelines. I tested tee --silent with success. src/tee.c | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/tee.c b/src/tee.c index c81faea91.

Re: [PATCH] tee: Add -q, --quiet option to not write to stdout

2021-01-21 Thread Alejandro Colomar (man-pages)
[CC += mtk, linux-api, freebsd, openbsd] On 1/21/21 10:26 PM, Alejandro Colomar (man-pages) wrote: > Hi Berny, > > On 1/21/21 10:01 PM, Bernhard Voelker wrote: >> On 1/21/21 7:39 PM, Alex Henrie wrote: >>> That said, I would love to see `tee -q` added to a future r

[PATCH] : Add safety to nitems(): check that argument is an array

2020-09-28 Thread Alejandro Colomar
te the array length. It does what nitems(_a) did before this patch. I'd like to put the contents of this patch in the public domain. Feel free to do anything with it. Signed-off-by: Alejandro Colomar --- Hi, I sent a patch like this one to glibc a few days ago. I hope it's good for yo

[PATCH] printf: Add %B conversion specifier for binary

2020-04-27 Thread Alejandro Colomar
er to glibc. They are concerned about adding a new non-standard specifier, but if more C libs are going to add it at the same time, it may become a thing. Alex. From 1a41d44571ccaf9ffaf36b2c2b96dd34e48eb5b7 Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Mon, 27 Apr 2