Fix: worker structure is leaked in run_as process
[lttng-tools.git] / src / common / runas.c
index d4a8e6c9c6b8397b0fe318a240df024ed2ed6442..1f2a836308e5006565c7eea73a436da2d558e57f 100644 (file)
@@ -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);
@@ -657,6 +661,7 @@ int run_as_create_worker(char *procname)
                        ret = -1;
                }
                worker->sockpair[1] = -1;
+               free(worker);
                LOG(ret ? PRINT_ERR : PRINT_DBG, "run_as worker exiting (ret = %d)", ret);
                exit(ret ? EXIT_FAILURE : EXIT_SUCCESS);
        } else {
This page took 0.025884 seconds and 4 git commands to generate.