From: Mathieu Desnoyers Date: Mon, 8 May 2017 12:15:20 +0000 (-0400) Subject: Cleanup: initialize data to 0 X-Git-Tag: v2.8.7~17 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=05019b80c3829b30a3da62b912b1070c9e3b918f;p=lttng-tools.git Cleanup: initialize data to 0 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 --- 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);