From 7c0407c5ca538f5e9e3dbff712971141db4a9afb Mon Sep 17 00:00:00 2001 From: Arturo Borrero Gonzalez Date: Mon, 1 Jul 2019 12:52:48 +0200 Subject: 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 Signed-off-by: Pablo Neira Ayuso --- src/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index cbfd69a4..8e6c897c 100644 --- a/src/main.c +++ b/src/main.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -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) -- cgit v1.2.3