From e2a2a24a8e78427ff8667d625f5befbe88c328bb Mon Sep 17 00:00:00 2001 From: Kamil Rytarowski Date: Wed, 23 Sep 2020 04:20:05 +0200 Subject: [PATCH] Preinitialize the sockaddr_un variable to zero 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 | 5 ++++- gdbsupport/agent.cc | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog index 91435ff1e8e..216fad129c4 100644 --- a/gdbsupport/ChangeLog +++ b/gdbsupport/ChangeLog @@ -1,3 +1,7 @@ +2020-10-01 Kamil Rytarowski + + * agent.cc (gdb_connect_sync_socket): Preinitialize addr with zeros. + 2020-09-29 Pedro Alves * valid-expr.h (CHECK_VALID_EXPR_INT): Make archetype a template @@ -327,4 +331,3 @@ * acinclude.m4, aclocal.m4, config.in, configure, configure.ac, Makefile.am, Makefile.in, README: New files. * Moved from ../gdb/gdbsupport/ - 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.30.2