Fix bug GH-11246 cli/get_set_process_title

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
This commit is contained in:
James Lucas 2023-05-16 10:37:42 +10:00 committed by Ilija Tovilo
parent c50172e812
commit c6ae7a55b7
No known key found for this signature in database
GPG Key ID: A4F5D403F118200A
2 changed files with 12 additions and 7 deletions

4
NEWS
View File

@ -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)

View File

@ -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];