bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* gl_{,SN}PRINTF_DIRECTIVE_N wrongly fail on Ubuntu 18.04
@ 2020-03-08 11:19 Adrian Bunk
  2020-03-08 17:59 ` Bruno Haible
  0 siblings, 1 reply; 8+ messages in thread
From: Adrian Bunk @ 2020-03-08 11:19 UTC (permalink / raw)
  To: bug-gnulib

rpl_fprintf is wrongly being used on Ubuntu 18.04 due to:

$ cat test.c
/* gl_PRINTF_DIRECTIVE_N */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char fmtstring[10];
static char buf[100];
int main ()
{
  int count = -1;
  /* Copy the format string.  Some systems (glibc with _FORTIFY_SOURCE=2)
     support %n in format strings in read-only memory but not in writable
     memory.  */
  strcpy (fmtstring, "%d %n");
  if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0
      || strcmp (buf, "123 ") != 0
      || count != 4)
    return 1;
  return 0;
}
$ gcc -O2 test.c -o test && ./test
*** %n in writable segment detected ***
Aborted
$ 

cu
Adrian


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

end of thread, other threads:[~2020-03-16 15:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-08 11:19 gl_{,SN}PRINTF_DIRECTIVE_N wrongly fail on Ubuntu 18.04 Adrian Bunk
2020-03-08 17:59 ` Bruno Haible
2020-03-08 18:46   ` Adrian Bunk
2020-03-08 22:04     ` Bruno Haible
2020-03-08 23:38       ` Adrian Bunk
2020-03-09  0:11         ` Bruno Haible
2020-03-09  3:36           ` Paul Eggert
2020-03-16 13:17       ` Bruno Haible

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 read-only IMAP folder(s) and NNTP newsgroup(s).