On Thu, Jul 04, 2019 at 12:21:23PM +0200, Phil Sutter wrote: > Hi Arturo, > > On Mon, Jul 01, 2019 at 12:52:48PM +0200, Arturo Borrero Gonzalez wrote: > > 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@xxxxxxxxxxxxx> > > This series breaks builds for me. Seems you missed xfree() and xmalloc() > used in src/main.c and src/cli.c. Hm, this did not break here for me. Patch is attached.
>From e4e5d4a4bd460194c330848cde1e0e96cdba9ce9 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> Date: Thu, 4 Jul 2019 14:38:37 +0200 Subject: [PATCH nft] src: use malloc() and free() from cli and main xmalloc() and xfree() are internal symbols of the library, do not use them. Fixes: 16543a0136c0 ("libnftables: export public symbols only") Reported-by: Phil Sutter <phil@xxxxxx> Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- src/cli.c | 9 ++++++--- src/main.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cli.c b/src/cli.c index ca3869abe335..3015fdcb0b1f 100644 --- a/src/cli.c +++ b/src/cli.c @@ -63,9 +63,12 @@ static char *cli_append_multiline(char *line) rl_set_prompt(".... "); } else { len += strlen(multiline); - s = xmalloc(len + 1); + s = malloc(len + 1); + if (!s) + return NULL; + snprintf(s, len + 1, "%s%s", multiline, line); - xfree(multiline); + free(multiline); multiline = s; } line = NULL; @@ -111,7 +114,7 @@ static void cli_complete(char *line) add_history(line); nft_run_cmd_from_buffer(cli_nft, line); - xfree(line); + free(line); } static char **cli_completion(const char *text, int start, int end) diff --git a/src/main.c b/src/main.c index 8e6c897cdd36..694611224d07 100644 --- a/src/main.c +++ b/src/main.c @@ -329,7 +329,7 @@ int main(int argc, char * const *argv) exit(EXIT_FAILURE); } - xfree(buf); + free(buf); nft_ctx_free(nft); return rc; -- 2.11.0