Skip to content

Commit c6ae7a5

Browse files
lucasnetauiluuu1994
authored andcommitted
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
1 parent c50172e commit c6ae7a5

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.1.21
44

5+
- CLI:
6+
. Fixed bug GH-11246 (cli/get_set_process_title fails on MacOS).
7+
(James Lucas)
8+
59
- Core:
610
. Fixed build for the riscv64 architecture/GCC 12. (Daniil Gentili)
711

sapi/cli/ps_title.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,20 @@ char** save_ps_args(int argc, char** argv)
167167
end_of_area = argv[i] + strlen(argv[i]);
168168
}
169169

170+
if (non_contiguous_area != 0) {
171+
goto clobber_error;
172+
}
173+
170174
/*
171175
* check for contiguous environ strings following argv
172176
*/
173-
for (i = 0; (non_contiguous_area == 0) && (environ[i] != NULL); i++)
177+
for (i = 0; environ[i] != NULL; i++)
174178
{
175-
if (end_of_area + 1 != environ[i])
176-
non_contiguous_area = 1;
177-
end_of_area = environ[i] + strlen(environ[i]);
179+
if (end_of_area + 1 == environ[i]) {
180+
end_of_area = environ[i] + strlen(environ[i]);
181+
}
178182
}
179183

180-
if (non_contiguous_area != 0)
181-
goto clobber_error;
182-
183184
ps_buffer = argv[0];
184185
ps_buffer_size = end_of_area - argv[0];
185186

0 commit comments

Comments
 (0)