php / php/php-src

Invalid values for upload_max_filesize cause undefined behavior.

Abierto
#14,695 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Category: Configuration Feature
Lenguaje dominante
C
Estrellas
40.4k
Forks
8.1k
Merge medio
2 d 13 h
PR fusionados (30 d)
96

Descripción

Description

If the value for upload_max_filesize is set to a non numeric value in the php.ini then it's not clear how the system is going to behave. For instance set
upload_max_filesize = bogus
in the php.ini file.

ini_get and phpinfo return the bogus string. As far as I can tell there is no limit enforced on uploads in this case but no warnings or errors are reported. This behavior is undocumented.

Other invalid values produce different results
upload_max_filesize = 1zz

Appears to set the limit to 1 byte. In general it appears that trailing input is ignored. This makes it very difficult to interpret the results of ini_get because that will return the value as it exists in the ini file but without knowing the exact rules it's impossible to convert this to the actual limit that PHP will enforce. In turn this makes it difficult to write diagnostic tools to try to detect why uploads are failing and suggest to users how to fix it.

Ideally to the extent that PHP is normalizing the value in the ini file, ini_get should return the normalized value that PHP is using. A completely invalid value should probably not be interpreted as "no limit whatsoever". That seems to invite an unfortunate typo turning into a potential DOS issue.

PHP Version

PHP 8.3.0

Operating System

Windows 10

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza reproduciendo los casos de upload_max_filesize en php.ini, incluidos bogus y 1zz, y compara después el límite de carga aplicado con ini_get y phpinfo. Traza cómo PHP analiza y aplica esta configuración. Se considera terminado cuando los valores no válidos tienen un comportamiento documentado y coherente, y el valor informado se puede interpretar de forma fiable.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
php
Área
backend
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.