Skip to content
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.

Multiple -Werror=format-overflow= errors in container.c #364

Open
jonathonf opened this issue Nov 1, 2018 · 1 comment
Open

Multiple -Werror=format-overflow= errors in container.c #364

jonathonf opened this issue Nov 1, 2018 · 1 comment
Assignees

Comments

@jonathonf
Copy link

Building hyperstart 1.1.0 with GCC 8.2:

container.c: In function ‘hyper_setup_container_rootfs’:
container.c:660:24: error: ‘/’ directive writing 1 byte into a region of size between 0 and 511 [-Werror=format-overflow=]
  sprintf(rootfs, "%s/%s/", root, container->rootfs);
                        ^
In file included from /usr/include/stdio.h:873,
                 from container.c:2:
/usr/include/bits/stdio2.h:36:10: note: ‘__builtin___sprintf_chk’ output 3 or more bytes (assuming 514) into a destination of size 512
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
container.c:282:18: error: ‘%s’ directive writing up to 511 bytes into a region of size 510 [-Werror=format-overflow=]
  sprintf(dst, "./%s", src);
                  ^~   ~~~
In file included from /usr/include/stdio.h:873,
                 from container.c:2:
/usr/include/bits/stdio2.h:36:10: note: ‘__builtin___sprintf_chk’ output between 3 and 514 bytes into a destination of size 512
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
container.c:238:24: error: ‘/_data’ directive writing 6 bytes into a region of size between 1 and 512 [-Werror=format-overflow=]
     sprintf(volume, "%s/_data", path);
                        ^~~~~~
In file included from /usr/include/stdio.h:873,
                 from container.c:2:
/usr/include/bits/stdio2.h:36:10: note: ‘__builtin___sprintf_chk’ output between 7 and 518 bytes into a destination of size 512
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
container.c:167:24: error: ‘/_data’ directive writing 6 bytes into a region of size between 0 and 511 [-Werror=format-overflow=]
    sprintf(volume, "/%s/_data", path);
                        ^~~~~~
In file included from /usr/include/stdio.h:873,
                 from container.c:2:
/usr/include/bits/stdio2.h:36:10: note: ‘__builtin___sprintf_chk’ output between 8 and 519 bytes into a destination of size 512
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
container.c:149:24: error: ‘/’ directive writing 1 byte into a region of size between 0 and 511 [-Werror=format-overflow=]
    sprintf(volume, "/%s/", path);
                        ^
In file included from /usr/include/stdio.h:873,
                 from container.c:2:
/usr/include/bits/stdio2.h:36:10: note: ‘__builtin___sprintf_chk’ output between 3 and 514 bytes into a destination of size 512
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
container.c:196:24: error: ‘/_data/’ directive writing 7 bytes into a region of size between 0 and 511 [-Werror=format-overflow=]
    sprintf(volume, "/%s/_data/%s", path, filevolume);
                        ^~~~~~~
In file included from /usr/include/stdio.h:873,
                 from container.c:2:
/usr/include/bits/stdio2.h:36:10: note: ‘__builtin___sprintf_chk’ output 9 or more bytes (assuming 520) into a destination of size 512
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@shirotech
Copy link

+1 same error

container.c: In function 'hyper_setup_container_rootfs':
container.c:660:24: error: '/' directive writing 1 byte into a region of size between 0 and 511 [-Werror=format-overflow=]
  sprintf(rootfs, "%s/%s/", root, container->rootfs);
                        ^
container.c:660:2: note: 'sprintf' output 3 or more bytes (assuming 514) into a destination of size 512
  sprintf(rootfs, "%s/%s/", root, container->rootfs);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
container.c:282:18: error: '%s' directive writing up to 511 bytes into a region of size 510 [-Werror=format-overflow=]
  sprintf(dst, "./%s", src);
                  ^~   ~~~
container.c:282:2: note: 'sprintf' output between 3 and 514 bytes into a destination of size 512
  sprintf(dst, "./%s", src);
  ^~~~~~~~~~~~~~~~~~~~~~~~~
container.c:238:24: error: '/_data' directive writing 6 bytes into a region of size between 1 and 512 [-Werror=format-overflow=]
     sprintf(volume, "%s/_data", path);
                        ^~~~~~
container.c:238:5: note: 'sprintf' output between 7 and 518 bytes into a destination of size 512
     sprintf(volume, "%s/_data", path);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
container.c:167:24: error: '/_data' directive writing 6 bytes into a region of size between 0 and 511 [-Werror=format-overflow=]
    sprintf(volume, "/%s/_data", path);
                        ^~~~~~
container.c:167:4: note: 'sprintf' output between 8 and 519 bytes into a destination of size 512
    sprintf(volume, "/%s/_data", path);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
container.c:149:24: error: '/' directive writing 1 byte into a region of size between 0 and 511 [-Werror=format-overflow=]
    sprintf(volume, "/%s/", path);
                        ^
container.c:149:4: note: 'sprintf' output between 3 and 514 bytes into a destination of size 512
    sprintf(volume, "/%s/", path);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
container.c:196:24: error: '/_data/' directive writing 7 bytes into a region of size between 0 and 511 [-Werror=format-overflow=]
    sprintf(volume, "/%s/_data/%s", path, filevolume);
                        ^~~~~~~
container.c:196:4: note: 'sprintf' output 9 or more bytes (assuming 520) into a destination of size 512
    sprintf(volume, "/%s/_data/%s", path, filevolume);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@teawater teawater self-assigned this Nov 22, 2018
teawater added a commit to teawater/hyperstart that referenced this issue Nov 26, 2018
Change sprintf to snprintf and check the return values of snprintf
to handle this warning.

Fixes: hyperhq#364

Signed-off-by: Hui Zhu <[email protected]>
teawater added a commit to teawater/hyperstart that referenced this issue Nov 26, 2018
Change sprintf to snprintf and check the return values of snprintf
to handle this warning.

Fixes: hyperhq#364

Signed-off-by: Hui Zhu <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants