diff options
author | Arturo Borrero Gonzalez <arturo@netfilter.org> | 2019-07-01 12:52:48 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-07-01 20:43:46 +0200 |
commit | 7c0407c5ca538f5e9e3dbff712971141db4a9afb (patch) | |
tree | 50dcfe9e5b47e9754729fab3fe4fd342a3395c11 /src/main.c | |
parent | a9b0c385a1d5e29dfa5d222e31a6ba7de338484a (diff) |
nft: don't use xzalloc()
In the current setup, nft (the frontend object) is using the xzalloc() function
from libnftables, which does not makes sense, as this is typically an internal
helper function.
In order to don't use this public libnftables symbol (a later patch just
removes it), let's use calloc() directly in the nft frontend.
Signed-off-by: Arturo Borrero Gonzalez <arturo@netfilter.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -19,6 +19,7 @@ #include <sys/types.h> #include <nftables/libnftables.h> +#include <nftables.h> #include <utils.h> #include <cli.h> @@ -302,7 +303,12 @@ int main(int argc, char * const *argv) for (len = 0, i = optind; i < argc; i++) len += strlen(argv[i]) + strlen(" "); - buf = xzalloc(len); + buf = calloc(1, len); + if (buf == NULL) { + fprintf(stderr, "%s:%u: Memory allocation failure\n", + __FILE__, __LINE__); + exit(NFT_EXIT_NOMEM); + } for (i = optind; i < argc; i++) { strcat(buf, argv[i]); if (i + 1 < argc) |