Potential signed-to-unsigned conversion in TIFF dimension parsing
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 62/100
Línea de trabajo
Empieza en ext/standard/image.c, en php_handle_tiff(), especialmente en el tratamiento de TAG_FMT_SSHORT y las asignaciones de IMAGEWIDTH/IMAGEHEIGHT identificadas en el issue. Comprueba cómo se validan los tipos de campo de dimensión TIFF y ejecuta las pruebas pertinentes de imagen/TIFF. Se considera terminado cuando los valores negativos con signo no pueden convertirse en dimensiones, mientras que las dimensiones válidas de tipo SHORT o LONG sin signo siguen funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
Hi, It seemed to me that a negative signed value could potentially be converted to a large unsigned value here.
A potential signed-to-unsigned conversion issue exists in php_handle_tiff() when processing TIFF image dimensions.
The entry_value variable is declared as size_t, while the TAG_FMT_SSHORT case assigns the return value of php_ifd_get16s() to it:
case TAG_FMT_SSHORT:
entry_value = php_ifd_get16s(dir_entry+8, motorola_intel);
break;
php_ifd_get16s() returns a signed 16-bit value. Therefore, a negative value from the TIFF input can be converted to a large unsigned size_t value.
If such an entry is subsequently identified as TAG_IMAGEWIDTH or TAG_IMAGEHEIGHT, the converted value is assigned to width or height:
case TAG_IMAGEWIDTH:
case TAG_COMP_IMAGEWIDTH:
width = entry_value;
break;
case TAG_IMAGEHEIGHT:
case TAG_COMP_IMAGEHEIGHT:
height = entry_value;
break;
For example, a signed value of -1 can be converted to the maximum value of size_t instead of remaining negative.
According to the TIFF 6.0 specification, ImageWidth and ImageLength use the SHORT or LONG types, where SHORT is an unsigned 16-bit integer. The reader is expected to validate the field type.
Impact
A malformed TIFF containing a negative SSHORT value for an image dimension can therefore cause the parser to produce an unexpectedly large width or height.
Proposed solution
Validate the signed value before assigning it to the unsigned entry_value variable and reject negative values.
PHP Version
PHP 8.3.31 (CLI)
Operating System
Ubuntu 24.04
- Lenguaje dominante
- C
- Estrellas
- 40.4k
- Forks
- 8.2k
- Merge medio
- 2 d 59 min
- PR fusionados (30 d)
- 155
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
-
Feature Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
php/php-src#24183 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Sockets from synchronous stream_socket_client() are left in non-blocking mode on WindowsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. AbiertoBug Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
sapi_lsapi_ub_write does not return bytes written in lsapi modePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. AbiertoBug Status: Needs Triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
Bug Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Use of PIDFile= in php-fpm.servicePosiblemente ocupada @CodedByManish la tomó hace 30 días. AbiertoBug SAPI: fpm Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
php/php-src#21740 · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de php/php-src
Issues similares
-
docs: AGENTS.md has no rule against running deploy scripts into the owner's game installPosiblemente ocupada @thesprockee la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
EchoTools/nevr-runtime#524 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
Genymobile/scrcpy#7097 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
-
type: feature
Dificultad 1/5 Menos de una hora Aptitud para principiantes 77/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día