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