]> git.ipfire.org Git - thirdparty/suricata.git/commit
radix: fix risky malloc call 2836/head
authorVictor Julien <victor@inliniac.net>
Thu, 13 Jul 2017 08:04:47 +0000 (10:04 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 13 Jul 2017 09:45:44 +0000 (11:45 +0200)
commitc9077093528f841ecfdbb1b9487cc8f6f04f79cc
treef541bb6c3e623cc1abda261342ada2959aba2713
parentf77412dce5c202298dc1fd0e53a251e839b3790b
radix: fix risky malloc call

GCC7 said:
  CC       util-radix-tree.o
In file included from util-debug-filters.h:29:0,
                 from util-debug.h:34,
                 from suricata-common.h:421,
                 from util-radix-tree.c:26:
util-radix-tree.c: In function ‘SCRadixAddKey’:
util-mem.h:177:12: error: argument 1 range [1844674407156206796818446744073709551615] exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
     ptrmem = malloc((a)); \
     ~~~~~~~^~~~~~~~~~~~~
util-radix-tree.c:749:42: note: in expansion of macro ‘SCMalloc’
             if ( (inter_node->netmasks = SCMalloc((node->netmask_cnt - i) *
                                          ^~~~~~~~
In file included from suricata-common.h:69:0,
                 from util-radix-tree.c:26:
/usr/include/stdlib.h:443:14: note: in a call to allocation function ‘malloc’ declared here
 extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
              ^~~~~~

scan-build said:
util-radix-tree.c:749:42: warning: Call to 'malloc' has an allocation size of 0 bytes
            if ( (inter_node->netmasks = SCMalloc((node->netmask_cnt - i) *
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-mem.h:177:14: note: expanded from macro 'SCMalloc'
    ptrmem = malloc((a)); \
             ^~~~~~~~~~~
1 warning generated.
src/util-radix-tree.c