Skip to content

Commit

Permalink
Fix bug GH-11246 cli/get_set_process_title
Browse files Browse the repository at this point in the history
Fail to clobber_error only when the argv is a non-contiguous area
Don't increment the end_of_error if a non-contiguous area is encountered in environ

Closes GH-11247
  • Loading branch information
lucasnetau authored and iluuu1994 committed May 31, 2023
1 parent c50172e commit c6ae7a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions NEWS
Expand Up @@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.1.21

- CLI:
. Fixed bug GH-11246 (cli/get_set_process_title fails on MacOS).
(James Lucas)

- Core:
. Fixed build for the riscv64 architecture/GCC 12. (Daniil Gentili)

Expand Down
15 changes: 8 additions & 7 deletions sapi/cli/ps_title.c
Expand Up @@ -167,19 +167,20 @@ char** save_ps_args(int argc, char** argv)
end_of_area = argv[i] + strlen(argv[i]);
}

if (non_contiguous_area != 0) {
goto clobber_error;
}

/*
* check for contiguous environ strings following argv
*/
for (i = 0; (non_contiguous_area == 0) && (environ[i] != NULL); i++)
for (i = 0; environ[i] != NULL; i++)
{
if (end_of_area + 1 != environ[i])
non_contiguous_area = 1;
end_of_area = environ[i] + strlen(environ[i]);
if (end_of_area + 1 == environ[i]) {
end_of_area = environ[i] + strlen(environ[i]);
}
}

if (non_contiguous_area != 0)
goto clobber_error;

ps_buffer = argv[0];
ps_buffer_size = end_of_area - argv[0];

Expand Down

0 comments on commit c6ae7a5

Please sign in to comment.