Preinitialize the sockaddr_un variable to zero
authorKamil Rytarowski <n54@gmx.com>
Wed, 23 Sep 2020 02:20:05 +0000 (04:20 +0200)
committerKamil Rytarowski <n54@gmx.com>
Thu, 1 Oct 2020 22:38:12 +0000 (00:38 +0200)
Don't pass random sun_len for the BSD's,
zero the whole structure as recommended for portability.

Reported by Coverity.

gdbsupport/ChangeLog:

* agent.cc (gdb_connect_sync_socket): Preinitialize addr with zeros.

gdbsupport/ChangeLog
gdbsupport/agent.cc

index 91435ff1e8e6966cf4d0b8d8737aa2239a8f51e1..216fad129c4ecd4e2710e9f3884ba5ad58f8b989 100644 (file)
@@ -1,3 +1,7 @@
+2020-10-01  Kamil Rytarowski  <n54@gmx.com>
+
+       * agent.cc (gdb_connect_sync_socket): Preinitialize addr with zeros.
+
 2020-09-29  Pedro Alves  <pedro@palves.net>
 
        * valid-expr.h (CHECK_VALID_EXPR_INT): Make archetype a template
        * acinclude.m4, aclocal.m4, config.in, configure, configure.ac,
        Makefile.am, Makefile.in, README: New files.
        * Moved from ../gdb/gdbsupport/
-
index b4127ff6bafad492c84451c7b788c564896ed837..9588e1ff309474cdb47a9a72a16f0321dd079b7a 100644 (file)
@@ -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];