[PATCH 2/5] Preinitialize the sockaddr_un variable to zero

Kamil Rytarowski
2020-09-23T04:26:34Z

Fix portability issue as passing random sun_len is not portable.

gdbsupport/ChangeLog:

* agent.cc (gdb_connect_sync_socket): Preinitialize addr with zeros.
---
gdbsupport/ChangeLog | 4 ++++
gdbsupport/agent.cc | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog
index d46f8c77bb0..36961c90cfd 100644
--- a/gdbsupport/ChangeLog
+++ b/gdbsupport/ChangeLog
@@ -1,3 +1,7 @@
+2020-09-23 Kamil Rytarowski <n54@gmx.com>
+
+ * agent.cc (gdb_connect_sync_socket): Preinitialize addr with zeros.
+
2020-09-16 John Baldwin <jhb@FreeBSD.org>

* common.m4 (GDB_AC_COMMON): Refactor checks for kinfo_getfile().
diff --git a/gdbsupport/agent.cc b/gdbsupport/agent.cc
index b4127ff6baf..9588e1ff309 100644
--- a/gdbsupport/agent.cc
+++ b/gdbsupport/agent.cc
@@ -138,7 +138,7 @@ static int
gdb_connect_sync_socket (int pid)
{
#ifdef HAVE_SYS_UN_H
- struct sockaddr_un addr;
+ struct sockaddr_un addr = {};
int res, fd;
char path[UNIX_PATH_MAX];

--
2.28.0