From 05019b80c3829b30a3da62b912b1070c9e3b918f Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 8 May 2017 08:15:20 -0400 Subject: [PATCH] Cleanup: initialize data to 0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Valgrind catches read of uninitialized data caused by the on-stack "data" argument which ends up not being fully initialized (it contains a union). Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- src/common/runas.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/runas.c b/src/common/runas.c index 7a6be2837..3e700c02d 100644 --- a/src/common/runas.c +++ b/src/common/runas.c @@ -466,6 +466,7 @@ int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid) { struct run_as_data data; + memset(&data, 0, sizeof(data)); DBG3("mkdir() recursive %s with mode %d for uid %d and gid %d", path, (int) mode, (int) uid, (int) gid); strncpy(data.u.mkdir.path, path, PATH_MAX - 1); @@ -479,6 +480,7 @@ int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid) { struct run_as_data data; + memset(&data, 0, sizeof(data)); DBG3("mkdir() %s with mode %d for uid %d and gid %d", path, (int) mode, (int) uid, (int) gid); strncpy(data.u.mkdir.path, path, PATH_MAX - 1); @@ -496,6 +498,7 @@ int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid) { struct run_as_data data; + memset(&data, 0, sizeof(data)); DBG3("open() %s with flags %X mode %d for uid %d and gid %d", path, flags, (int) mode, (int) uid, (int) gid); strncpy(data.u.open.path, path, PATH_MAX - 1); @@ -510,6 +513,7 @@ int run_as_unlink(const char *path, uid_t uid, gid_t gid) { struct run_as_data data; + memset(&data, 0, sizeof(data)); DBG3("unlink() %s with for uid %d and gid %d", path, (int) uid, (int) gid); strncpy(data.u.unlink.path, path, PATH_MAX - 1); -- 2.34.1