diff --git a/0004-isnsadm-free-qry-in-error-paths.patch b/0004-isnsadm-free-qry-in-error-paths.patch new file mode 100644 index 0000000000000000000000000000000000000000..0322498073ea8c6c32182a4f54e4f77a430504c7 --- /dev/null +++ b/0004-isnsadm-free-qry-in-error-paths.patch @@ -0,0 +1,75 @@ +From c542da377c3dc070e081c1d26e74531d75f236cc Mon Sep 17 00:00:00 2001 +From: Chris Leech +Date: Tue, 26 Mar 2024 12:55:45 -0700 +Subject: [PATCH] isnsadm: free qry in error paths + +There are multiple error handling paths in query_objects and +query_entity_id that do not free the qry allocation. + +I realize that isnsadm is a short lived process, and memory leaks are +not an issue, but this will keep static checkers quiet. + +Signed-off-by: Chris Leech + +--- + isnsadm.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/isnsadm.c b/isnsadm.c +index 0710877..c4d2264 100644 +--- a/isnsadm.c ++++ b/isnsadm.c +@@ -619,20 +619,20 @@ query_objects(isns_client_t *clnt, int argc, char **argv) + status = isns_client_call(clnt, &qry); + if (status != ISNS_SUCCESS) { + isns_error("Query failed: %s\n", isns_strerror(status)); +- return status; ++ goto out; + } + + status = isns_query_response_get_objects(qry, &objects); + if (status) { + isns_error("Unable to extract object list from query response: %s\n", + isns_strerror(status), status); +- return status; ++ goto out; + } + + isns_object_list_print(&objects, isns_print_stdout); + isns_object_list_destroy(&objects); ++out: + isns_simple_free(qry); +- + return status; + } + +@@ -664,14 +664,14 @@ query_entity_id(isns_client_t *clnt, int argc, char **argv) + status = isns_client_call(clnt, &qry); + if (status != ISNS_SUCCESS) { + isns_error("Query failed: %s\n", isns_strerror(status)); +- return status; ++ goto out; + } + + status = isns_query_response_get_objects(qry, &objects); + if (status) { + isns_error("Unable to extract object list from query response: %s\n", + isns_strerror(status), status); +- return status; ++ goto out; + } + + status = ISNS_NO_SUCH_ENTRY; +@@ -689,8 +689,8 @@ query_entity_id(isns_client_t *clnt, int argc, char **argv) + } + + isns_object_list_destroy(&objects); ++out: + isns_simple_free(qry); +- + return status; + } + +-- +2.27.0 + diff --git a/0005-isnsadm-more-memleaks-in-error-handling-paths.patch b/0005-isnsadm-more-memleaks-in-error-handling-paths.patch new file mode 100644 index 0000000000000000000000000000000000000000..690d5e1b59e773a9226bd53ea0bc9354159b0a11 --- /dev/null +++ b/0005-isnsadm-more-memleaks-in-error-handling-paths.patch @@ -0,0 +1,167 @@ +From 1c070ce18aa25e4a9a309f5b8edb1fece772c70e Mon Sep 17 00:00:00 2001 +From: Chris Leech +Date: Tue, 26 Mar 2024 13:01:43 -0700 +Subject: [PATCH] isnsadm: more memleaks in error handling paths + +I realize that isnsadm is a short lived process, and memory leaks are +not an issue, but this will keep static checkers quiet. + +Signed-off-by: Chris Leech + +--- + 0001-free-qry-in-error-paths.patch | 67 ++++++++++++++++++++++++++++++ + isnsadm.c | 16 +++---- + 2 files changed, 75 insertions(+), 8 deletions(-) + create mode 100644 0001-free-qry-in-error-paths.patch + +diff --git a/0001-free-qry-in-error-paths.patch b/0001-free-qry-in-error-paths.patch +new file mode 100644 +index 0000000..65ad7fb +--- /dev/null ++++ b/0001-free-qry-in-error-paths.patch +@@ -0,0 +1,67 @@ ++From c44ececc5854de592dd28d07de2b24fd0bc5e179 Mon Sep 17 00:00:00 2001 ++From: yanshuai01 ++Date: Thu, 26 Sep 2024 14:36:54 +0800 ++Subject: [PATCH] free qry in error paths ++ ++--- ++ isnsadm.c | 12 ++++++------ ++ 1 file changed, 6 insertions(+), 6 deletions(-) ++ ++diff --git a/isnsadm.c b/isnsadm.c ++index 0710877..c4d2264 100644 ++--- a/isnsadm.c +++++ b/isnsadm.c ++@@ -619,20 +619,20 @@ query_objects(isns_client_t *clnt, int argc, char **argv) ++ status = isns_client_call(clnt, &qry); ++ if (status != ISNS_SUCCESS) { ++ isns_error("Query failed: %s\n", isns_strerror(status)); ++- return status; +++ goto out; ++ } ++ ++ status = isns_query_response_get_objects(qry, &objects); ++ if (status) { ++ isns_error("Unable to extract object list from query response: %s\n", ++ isns_strerror(status), status); ++- return status; +++ goto out; ++ } ++ ++ isns_object_list_print(&objects, isns_print_stdout); ++ isns_object_list_destroy(&objects); +++out: ++ isns_simple_free(qry); ++- ++ return status; ++ } ++ ++@@ -664,14 +664,14 @@ query_entity_id(isns_client_t *clnt, int argc, char **argv) ++ status = isns_client_call(clnt, &qry); ++ if (status != ISNS_SUCCESS) { ++ isns_error("Query failed: %s\n", isns_strerror(status)); ++- return status; +++ goto out; ++ } ++ ++ status = isns_query_response_get_objects(qry, &objects); ++ if (status) { ++ isns_error("Unable to extract object list from query response: %s\n", ++ isns_strerror(status), status); ++- return status; +++ goto out; ++ } ++ ++ status = ISNS_NO_SUCH_ENTRY; ++@@ -689,8 +689,8 @@ query_entity_id(isns_client_t *clnt, int argc, char **argv) ++ } ++ ++ isns_object_list_destroy(&objects); +++out: ++ isns_simple_free(qry); ++- ++ return status; ++ } ++ ++-- ++2.27.0 ++ +diff --git a/isnsadm.c b/isnsadm.c +index c4d2264..2e0b497 100644 +--- a/isnsadm.c ++++ b/isnsadm.c +@@ -630,8 +630,8 @@ query_objects(isns_client_t *clnt, int argc, char **argv) + } + + isns_object_list_print(&objects, isns_print_stdout); +- isns_object_list_destroy(&objects); + out: ++ isns_object_list_destroy(&objects); + isns_simple_free(qry); + return status; + } +@@ -688,8 +688,8 @@ query_entity_id(isns_client_t *clnt, int argc, char **argv) + status = ISNS_SUCCESS; + } + +- isns_object_list_destroy(&objects); + out: ++ isns_object_list_destroy(&objects); + isns_simple_free(qry); + return status; + } +@@ -856,7 +856,7 @@ deregister_objects(isns_client_t *clnt, int argc, char **argv) + if (status != ISNS_SUCCESS) { + isns_error("Deregistration failed: %s\n", + isns_strerror(status)); +- return status; ++ goto out; + } + + #if 0 +@@ -869,9 +869,9 @@ deregister_objects(isns_client_t *clnt, int argc, char **argv) + isns_object_list_print(&objects, isns_print_stdout); + #endif + ++out: + isns_object_list_destroy(&objects); + isns_simple_free(dereg); +- + return status; + } + +@@ -919,7 +919,7 @@ register_domain(isns_client_t *clnt, int argc, char **argv) + if (status != ISNS_SUCCESS) { + isns_error("Registration failed: %s\n", + isns_strerror(status)); +- return status; ++ goto out; + } + + if (status == ISNS_SUCCESS) { +@@ -928,8 +928,8 @@ register_domain(isns_client_t *clnt, int argc, char **argv) + isns_simple_get_attrs(msg), + isns_print_stdout); + } ++out: + isns_simple_free(msg); +- + return status; + } + +@@ -976,9 +976,9 @@ deregister_domain(isns_client_t *clnt, int argc, char **argv) + if (status != ISNS_SUCCESS) { + isns_error("Deregistration failed: %s\n", + isns_strerror(status)); +- return status; ++ goto out; + } +- ++out: + isns_simple_free(msg); + return status; + } +-- +2.27.0 + diff --git a/open-isns.spec b/open-isns.spec index 47b96267c42a612d7ec925ffc5e60518276abeee..857e790e150b0c2c68aa39e56b7a980aa8a8d045 100644 --- a/open-isns.spec +++ b/open-isns.spec @@ -1,6 +1,6 @@ Name: open-isns Version: 0.101 -Release: 3 +Release: 4 Summary: The iSNS server and client programs License: LGPLv2+ URL: https://www.github.com/open-iscsi/open-isns @@ -9,6 +9,8 @@ Source0: https://www.github.com/open-iscsi/open-isns/archive/v%{version}. Patch0001: 0001-Do-not-install-isnsd.socket-in-isnsd.service.patch Patch0002: 0002-isnsadm-Fix-unparse-command-line-options-V-and-r.patch Patch0003: 0003-isnsd-socket-Make-sure-to-create-IPv6-socket-default.patch +Patch0004: 0004-isnsadm-free-qry-in-error-paths.patch +Patch0005: 0005-isnsadm-more-memleaks-in-error-handling-paths.patch BuildRequires: gcc systemd automake autoconf make BuildRequires: openssl-devel systemd-devel @@ -97,6 +99,10 @@ install -p -m 644 isnsd.service %{buildroot}%{_unitdir}/isnsd.service %{_mandir}/man8/* %changelog +* Thu Sep 26 2024 yanshuai - 0.101-4 +- isnsadm: free qry in error paths +- isnsadm: more memleaks in error handling paths + * Fri Sep 2 2022 Wenchao Hao - 0.101-3 - isnsd: socket: Make sure to isnsd would listen IPv6 socket default