From 4c899ff5a643869823ab006b4dda086afba4ac9f Mon Sep 17 00:00:00 2001 From: Danilo Egea Gondolfo Date: Mon, 14 Aug 2023 10:31:01 +0100 Subject: [PATCH 1/2] util: prevent calling close() on negative descriptor Coverity IDs: 398341, 398338 --- src/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util.c b/src/util.c index 92e09a6e8..bbdeedad9 100644 --- a/src/util.c +++ b/src/util.c @@ -388,12 +388,12 @@ netplan_util_dump_yaml_subtree(const char* prefix, int input_fd, int output_fd, cleanup: if (input) fclose(input); - else + else if (in_dup >= 0) close(in_dup); if (output) fclose(output); - else + else if (out_dup >= 0) close(out_dup); if (yaml_path) From 772a2b770fe7e039baab2f3c3c2b6d969efefee5 Mon Sep 17 00:00:00 2001 From: Danilo Egea Gondolfo Date: Mon, 14 Aug 2023 10:35:51 +0100 Subject: [PATCH 2/2] parse: restore npp->current.route to NULL Coverity ID: 398340 --- src/parse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/parse.c b/src/parse.c index c0dc12dad..67549a249 100644 --- a/src/parse.c +++ b/src/parse.c @@ -2097,6 +2097,7 @@ handle_routes(NetplanParser* npp, yaml_node_t* node, __unused const void* _, GEr err: route_clear(&npp->current.route); + npp->current.route = NULL; return FALSE; }