[lxc-devel] [lxc/lxc] 091045: conf/ile: make sure buffer is large enough

GitHub noreply at github.com
Thu Feb 2 10:34:18 UTC 2017


  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: 091045f888b7d372f3f8d6870ca25a16109a9616
      https://github.com/lxc/lxc/commit/091045f888b7d372f3f8d6870ca25a16109a9616
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-02-02 (Thu, 02 Feb 2017)

  Changed paths:
    M src/lxc/conf.c
    M src/lxc/confile.c
    M src/lxc/utils.c

  Log Message:
  -----------
  conf/ile: make sure buffer is large enough

conf.c: In function 'lxc_assign_network':
conf.c:3096:25: error: '%lu' directive output may be truncated writing between 1 and 20 bytes into a region of size 19 [-Werror=format-truncation=]
   snprintf(pidstr, 19, "%lu", (unsigned long) pid);
                   ^~~
conf.c:3096:24: note: using the range [1, 18446744073709551615] for directive argument
   snprintf(pidstr, 19, "%lu", (unsigned long) pid);
                  ^~~~~
In file included from /usr/include/stdio.h:938:0,
           from conf.c:35:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: format output between 2 and 21 bytes into a destination of size 19
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  __bos (__s), __fmt, __va_arg_pack ());
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
confile.c: In function 'network_new_hwaddrs':
confile.c:2889:38: error: '%02x' directive output may be truncated writing between 2 and 8 bytes into a region of size 6 [-Werror=format-truncation=]
  snprintf(hwaddr, 18, "00:16:3e:%02x:%02x:%02x",
                                ^~~~
confile.c:2889:23: note: using the range [0, 4294967295] for directive argument
  snprintf(hwaddr, 18, "00:16:3e:%02x:%02x:%02x",
                 ^~~~~~~~~~~~~~~~~~~~~~~~~
confile.c:2889:23: note: using the range [0, 4294967295] for directive argument
In file included from /usr/include/stdio.h:938:0,
           from confile.c:24:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: format output between 18 and 36 bytes into a destination of size 18
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  __bos (__s), __fmt, __va_arg_pack ());
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Not sure whether the latter is really a problem. We might need an additional
fix later on.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 01b791a9d3a56386025019d92bf59e9f5475c747
      https://github.com/lxc/lxc/commit/01b791a9d3a56386025019d92bf59e9f5475c747
  Author: Stéphane Graber <stgraber at stgraber.org>
  Date:   2017-02-02 (Thu, 02 Feb 2017)

  Changed paths:
    M src/lxc/conf.c
    M src/lxc/confile.c
    M src/lxc/utils.c

  Log Message:
  -----------
  Merge pull request #1410 from brauner/2017-02-02/fix_compiler_error

conf/ile: make sure buffer is large enough


Compare: https://github.com/lxc/lxc/compare/9338493e96fa...01b791a9d3a5


More information about the lxc-devel mailing list