Skip to content

sprintf region overruns #168

@dimpase

Description

@dimpase

While building the current master, I see

gcc -g -O2 -g -O2 -Wall -D_GNU_SOURCE -I/mnt/opt/fricas/src/include -I/mnt/opt/fricas/config  \
    -I. -c -o htinp.o htinp.c
htinp.c: In function ‘send_command’:
htinp.c:399:58: warning: ‘%s’ directive writing up to 511 bytes into a region of size 478 [-Wformat-overflow=]
  399 |         sprintf(str, "(|parseAndEvalToHypertex| '\")read %s\")", name);
      |                                                          ^~      ~~~~
In file included from /usr/include/stdio.h:980,
                 from hyper.h:38,
                 from htinp.c:41:
In function ‘sprintf’,
    inlined from ‘send_command’ at htinp.c:399:9:
/usr/include/bits/stdio2.h:30:10: note: ‘__builtin___sprintf_chk’ output between 37 and 548 bytes into a destination of size 512
   30 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   31 |                                   __glibc_objsize (__s), __fmt,
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   32 |                                   __va_arg_pack ());
      |                                   ~~~~~~~~~~~~~~~~~

warnings emitted by gcc version 13.2.1 20240210 (Gentoo 13.2.1_p20240210 p14)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions