Windows CLI: get_ps_title() passes bytes to GetConsoleTitleW() instead of characters, overflowing the 260-wchar_t buffer
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 79/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- c
- Área
- cli, operating-systems
Línea de trabajo
Lee la llamada a GetConsoleTitleW() en sapi/cli/ps_title.c, alrededor de las líneas 407–436, y comprueba cómo se pasa la longitud del búfer. Empieza revisando cli_get_process_title_basic.phpt y cli_process_title_windows.phpt, que actualmente cubren títulos cortos. El trabajo estará terminado cuando la API reciba la capacidad del búfer en caracteres y un título largo de la consola se trunque sin provocar un fallo en Windows.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
In sapi/cli/ps_title.c (~L407-436), wchar_t ps_buffer_w[MAX_PATH] is filled by GetConsoleTitleW(ps_buffer_w, (DWORD)sizeof(ps_buffer_w)). nSize is a count of characters, so 520 is passed for a buffer of 260 wchar_t; the API may write up to 1040 bytes. The clamp after the call acts on a different buffer. PHP itself rejects titles of 260+ characters in set_ps_title(), so the console title has to be set by another process on the same console.
The following code (run from a console):
import ctypes, subprocess
ctypes.windll.kernel32.SetConsoleTitleW("A" * 500)
r = subprocess.run([r"C:\php\php.exe", "-r", "echo strlen(cli_get_process_title());"])
print(hex(r.returncode & 0xFFFFFFFF))
Resulted in this output:
0xC0000409 (STATUS_STACK_BUFFER_OVERRUN)
Title length 10 and 259 work; 260 prints 259; 500 aborts.
But I expected this output instead: 259 (truncated title), no crash.
Fix: GetConsoleTitleW(ps_buffer_w, (DWORD)_countof(ps_buffer_w)). Existing tests (cli_get_process_title_basic.phpt, cli_process_title_windows.phpt) only use short titles.
PHP Version
PHP 8.7.0-dev (cli) (built: Oct 27 2026 17:51:17) (ZTS Visual C++ 2026 x64)
Zend Engine v4.7.0-dev (master @ 0af8a091eec28513a6a0b758bcb10b430ba6c6de)
Affects PHP-8.4/8.5 by source inspection (not run there).
Operating System
Windows 11 x64
- Lenguaje dominante
- C
- Estrellas
- 41.7k
- Forks
- 8.5k
- Merge medio
- 2 d 10 h
- PR fusionados (30 d)
- 158
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de php/php-src
-
fileinfo: built-in magic database php_magic_database is not aligned, breaks on strict-alignment CPUs (ARMv5, 32-bit)Posiblemente ocupada @lazerg la tomó hoy. AbiertoBug Extension: fileinfo Status: Verified
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 1 día
-
master: part of the mbstring bailout fix got lost in a mergePosiblemente ocupada @lazerg la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Bug Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
-
quoted_printable_encode() produces lines longer than 76 characters for bytes 0xF5 to 0xFFPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Bug Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
php/php-src#24196 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de php/php-src
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
ly05010419/MacNativeGames#1340 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
area:stdlib bug found-by:cold-read kind:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
InauguralSystems/EigenScript#2197 ·
Los mantenedores suelen responder en 1 día
-
Hide the cursorAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
seedds/nxnative#675 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 2 días