mailing list of musl libc
 help / color / mirror / code / Atom feed
* Possible out of bounds memory write in initialization of xdigits in src/stdio/vfprintf.c
@ 2018-06-28 17:31 Mark Winterrowd
  2018-06-28 17:48 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Winterrowd @ 2018-06-28 17:31 UTC (permalink / raw)
  To: musl

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

Hi all,

On line 148 of src/stdio/vfprintf.c in the source tree head, you can
observe the following global initialization:

static const char xdigits[16] = {
"0123456789ABCDEF"
};

Note that while this xdigits array has a length of 16, the string it is
being initialized to has a length of 17, due to the implicit null
terminator. Thus, an additional '\0' will be written just past the end of
this global. I believe this could cause unpredictable effects depending
upon how the compiler and linker handle this situation.

The fix is simple, just write out a list of comma separated characters to
eliminate the null terminator or make xdigits have a length of 17.

Thanks,
Mark Winterrowd

[-- Attachment #2: Type: text/html, Size: 830 bytes --]

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

end of thread, other threads:[~2018-06-28 17:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-28 17:31 Possible out of bounds memory write in initialization of xdigits in src/stdio/vfprintf.c Mark Winterrowd
2018-06-28 17:48 ` Rich Felker

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).