diff mbox series

[ovs-dev,v2,4/6] socket: Fix uninitialized values in inet_parse_ functions.

Message ID 20240523191152.589605-4-mkp@redhat.com
State Changes Requested
Headers show
Series [ovs-dev,v2,1/6] netdev-offload: Fix null pointer dereference' warnings on dump creation. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Mike Pattrick May 23, 2024, 7:11 p.m. UTC
Clang's static analyzer will complain about uninitialized value
dns_failure because we weren't setting a value for dns_failure in all
code paths.

Now we initialize this in the error conditions of inet_parse_passive and
inet_parse_active.

Fixes: 08e9e5337383 ("ovsdb: raft: Fix inability to read the database with DNS host names.")
Fixes: 5f219af8b3c7 ("ovsdb-server: Fix handling of DNS name for listener configuration.")
Signed-off-by: Mike Pattrick <mkp@redhat.com>
---
 lib/socket-util.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/lib/socket-util.c b/lib/socket-util.c
index 2d89fce85..c569b7d16 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -546,9 +546,15 @@  inet_parse_active(const char *target_, int default_port,
     if (!host) {
         VLOG_ERR("%s: host must be specified", target_);
         ok = false;
+        if (dns_failure) {
+            *dns_failure = false;
+        }
     } else if (!port && default_port < 0) {
         VLOG_ERR("%s: port must be specified", target_);
         ok = false;
+        if (dns_failure) {
+            *dns_failure = false;
+        }
     } else {
         ok = parse_sockaddr_components(ss, host, port, default_port,
                                        target_, resolve_host, dns_failure);
@@ -671,6 +677,9 @@  inet_parse_passive(const char *target_, int default_port,
     if (!port && default_port < 0) {
         VLOG_ERR("%s: port must be specified", target_);
         ok = false;
+        if (dns_failure) {
+            *dns_failure = false;
+        }
     } else {
         ok = parse_sockaddr_components(ss, host, port, default_port,
                                        target_, resolve_host, dns_failure);