Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZjJbLnA97fek0itw@debian>
Date: Wed, 1 May 2024 17:09:34 +0200
From: Alejandro Colomar <alx@...nel.org>
To: musl@...ts.openwall.com
Subject: gcvt(3) should be MT-Safe, AS-Safe, AC-Safe

Hi,

glibc's gcvt(1) is documented to be MT-Safe | AS-Safe | AC-Safe.
<https://sourceware.org/glibc/manual/latest/html_mono/libc.html#index-gcvt>
It's an interesting function to be called from a signal handler, where
snprintf(3) is not available.

But musl implements it as a call to sprintf(3); that doesn't seem safe.

$ grepc gcvt .
./include/stdlib.h:char *gcvt(double, int, char *);
./src/stdlib/gcvt.c:char *gcvt(double x, int n, char *b)
{
	sprintf(b, "%.*g", n, x);
	return b;
}

Have a lovely day!
Alex

-- 
<https://www.alejandro-colomar.es/>

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.