hyperhq / hyperstart

The tiny Init service for HyperContainer
https://www.hypercontainer.io
Apache License 2.0
134 stars 63 forks source link

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

Open jonathonf opened 6 years ago

jonathonf commented 6 years ago

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 commented 6 years ago

+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);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~