mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-16 17:48:14 +00:00
util: always malloc for setproctitle
Closes #1407 Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
This commit is contained in:
parent
4ce84082f0
commit
be69ad435d
@ -1463,34 +1463,24 @@ int setproctitle(char *title)
|
|||||||
if (!tmp)
|
if (!tmp)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
i = sscanf(tmp, "%lu %lu %lu %lu %lu %lu %lu",
|
i = sscanf(tmp, "%lu %lu %lu %*u %*u %lu %lu",
|
||||||
&start_data,
|
&start_data,
|
||||||
&end_data,
|
&end_data,
|
||||||
&start_brk,
|
&start_brk,
|
||||||
&arg_start,
|
|
||||||
&arg_end,
|
|
||||||
&env_start,
|
&env_start,
|
||||||
&env_end);
|
&env_end);
|
||||||
if (i != 7)
|
if (i != 5)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Include the null byte here, because in the calculations below we
|
/* Include the null byte here, because in the calculations below we
|
||||||
* want to have room for it. */
|
* want to have room for it. */
|
||||||
len = strlen(title) + 1;
|
len = strlen(title) + 1;
|
||||||
|
|
||||||
/* If we don't have enough room by just overwriting the old proctitle,
|
proctitle = realloc(proctitle, len);
|
||||||
* let's allocate a new one.
|
if (!proctitle)
|
||||||
*/
|
return -1;
|
||||||
if (len > arg_end - arg_start) {
|
|
||||||
void *m;
|
|
||||||
m = realloc(proctitle, len);
|
|
||||||
if (!m)
|
|
||||||
return -1;
|
|
||||||
proctitle = m;
|
|
||||||
|
|
||||||
arg_start = (unsigned long) proctitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
arg_start = (unsigned long) proctitle;
|
||||||
arg_end = arg_start + len;
|
arg_end = arg_start + len;
|
||||||
|
|
||||||
brk_val = syscall(__NR_brk, 0);
|
brk_val = syscall(__NR_brk, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user