mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Potential bug in printf_core
@ 2021-08-06 13:14 Pontus Jensen Karlsson
  2021-08-06 14:20 ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: Pontus Jensen Karlsson @ 2021-08-06 13:14 UTC (permalink / raw)
  To: musl

Hi,

I've been trying to build audit-userspace tools for an ARMv7 SBC using 
musl 1.2.2 as libc.
The tool auditd continously segfaults and I've traced it to a printf 
statement that
I have isolated the issue to this piece of code (simplified for 
debugging purposes):

#include <sys/time.h>
#include <stdio.h>

int main(int argc, char **argv)
{
     struct timeval tv = {
         .tv_sec = 1000,
         .tv_usec = 4177777
     };
     char *str = "Hello World";
     unsigned num = 8062;

     printf("%lu %03u %u %s", tv.tv_sec, (unsigned)(tv.tv_usec), num, str);
}

This code segfaults at memchr (s = 0x3fbf71 <error: Cannot access memory 
at address 0x3fbf71>)
but three frames up we're at src/stdio/vfprintf.c:593.

Here it attempts to read the string length from the arg.p address, the 
problem is that arg.p points
to the int-value of (unsigned)(tv.tv_usec) and not the memory address of 
str.

So, I'm confused as to why this happens? Is it something weird with the 
state-machine in printf_core,
or am I misunderstanding something which needs to be patched into 
audit-userspace?

Best regards,
Pontus Jensen Karlsson



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

end of thread, other threads:[~2021-08-06 19:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06 13:14 [musl] Potential bug in printf_core Pontus Jensen Karlsson
2021-08-06 14:20 ` Rich Felker
2021-08-06 19:29   ` Pontus Jensen Karlsson
2021-08-06 19:35     ` Érico Nogueira
2021-08-06 19:36     ` 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).