diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-05-23 22:51:26 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-05-23 22:51:29 +0200 |
commit | f38c16748eb4a109b44c2e99c8ff377ddf3a23cf (patch) | |
tree | 751636e823ed58f6377be99dce734f0275965133 /libps | |
parent | a2b0f721d077fdc5c9decb21b975b58fb51a3e8f (diff) | |
download | hurd-f38c16748eb4a109b44c2e99c8ff377ddf3a23cf.tar.gz hurd-f38c16748eb4a109b44c2e99c8ff377ddf3a23cf.tar.bz2 hurd-f38c16748eb4a109b44c2e99c8ff377ddf3a23cf.zip |
libps: Fix allocating args/env
proc_getprocargs and proc_getprocenv read their size value
Diffstat (limited to 'libps')
-rw-r--r-- | libps/procstat.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/libps/procstat.c b/libps/procstat.c index 09c07e2a..4de4216d 100644 --- a/libps/procstat.c +++ b/libps/procstat.c @@ -921,12 +921,11 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags) /* The process's exec arguments */ if (NEED (PSTAT_ARGS, PSTAT_PID)) { - char *buf = malloc (100); - ps->args_len = 100; + mach_msg_type_number_t args_len = 100; + char *buf = malloc (args_len); ps->args = buf; if (ps->args) { - mach_msg_type_number_t args_len; if (proc_getprocargs (server, ps->pid, &ps->args, &args_len)) free (buf); else @@ -943,12 +942,11 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags) /* The process's exec environment */ if (NEED (PSTAT_ENV, PSTAT_PID)) { - char *buf = malloc (100); - ps->env_len = 100; + mach_msg_type_number_t env_len = 100; + char *buf = malloc (env_len); ps->env = buf; if (ps->env) { - mach_msg_type_number_t env_len; if (proc_getprocenv (server, ps->pid, &ps->env, &env_len)) free (buf); else |