mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] gcvt(3) should be MT-Safe, AS-Safe, AC-Safe
@ 2024-05-01 15:09 Alejandro Colomar
  2024-05-01 15:19 ` Leah Neukirchen
  0 siblings, 1 reply; 10+ messages in thread
From: Alejandro Colomar @ 2024-05-01 15:09 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 575 bytes --]

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/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-05-02 21:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-01 15:09 [musl] gcvt(3) should be MT-Safe, AS-Safe, AC-Safe Alejandro Colomar
2024-05-01 15:19 ` Leah Neukirchen
2024-05-01 15:38   ` Alejandro Colomar
2024-05-01 17:21     ` Rich Felker
2024-05-01 19:55       ` Alejandro Colomar
2024-05-01 23:04         ` Rich Felker
2024-05-01 23:45           ` Alejandro Colomar
2024-05-01 23:57             ` Thorsten Glaser
2024-05-02  0:01             ` Alejandro Colomar
2024-05-02 20:34               ` Joseph Myers

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).