[BUG] libc/time: strptime() numeric_range upper bound is off by one and accepts invalid dates/times
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
- 88/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- c
- Área
- operating-systems
Línea de trabajo
Empieza en libs/libc/time/lib_strptime.c e inspecciona numeric_range y los especificadores de formato que establecen min y range. Comprueba cómo el bucle de dígitos y la validación del límite superior gestionan los valores indicados y, después, ejecuta o añade pruebas específicas de strptime() para cada especificador afectado. Se considera terminado cuando los valores fuera de rango devuelven NULL y los rangos válidos indicados se siguen analizando correctamente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description / Steps to reproduce the issue
Summary
In libs/libc/time/lib_strptime.c, numeric_range checks *dest > min + range instead of *dest >= min + range:
*dest = 0;
for (i = 1; i <= min + range && isdigit(*s); i *= 10)
{
*dest = *dest * 10 + *s++ - '0';
}
if (*dest < min || *dest > min + range)
{
return NULL;
}
Root Cause
Every specifier jumping to numeric_range sets range to the count of valid values (so the inclusive upper bound is min + range - 1):
%H:min=0, range=24(valid0..23, accepts24)%M:min=0, range=60(valid0..59, accepts60)%S:min=0, range=61(valid0..60, accepts61)%m:min=1, range=12(valid1..12, accepts13->tm_mon = 12)%d/%e:min=1, range=31(valid1..31, accepts32)%I:min=1, range=12(valid1..12, accepts13)%j:min=1, range=366(valid1..366, accepts367)%w:min=0, range=7(valid0..6, accepts7)%u:min=1, range=7(valid1..7, accepts8)%U/%W:min=0, range=54(valid0..53, accepts54)%V:min=1, range=53(valid1..53, accepts54)
Steps to Reproduce
Compile libs/libc/time/lib_strptime.c and parse out-of-range values (Ubuntu 24.04, x86_64, gcc 13.3.0):
strptime("24:00:00", "%H:%M:%S"): glibc=NULL nuttx=MATCH
strptime("12:60:00", "%H:%M:%S"): glibc=NULL nuttx=MATCH
strptime("2026-13-01", "%Y-%m-%d"): glibc=NULL nuttx=MATCH
strptime("2026-01-32", "%Y-%m-%d"): glibc=NULL nuttx=MATCH
strptime("13", "%I"): glibc=NULL nuttx=MATCH
strptime("367", "%j"): glibc=NULL nuttx=MATCH
strptime("7", "%w"): glibc=NULL nuttx=MATCH
strptime("8", "%u"): glibc=NULL nuttx=MATCH
strptime("54", "%U"): glibc=NULL nuttx=MATCH
strptime("54", "%V"): glibc=NULL nuttx=MATCH
Expected Behavior
Use i <= min + range - 1 for the digit loop and reject *dest < min || *dest >= min + range with NULL.
On which OS does this issue occur?
[OS: Linux]
What is the version of your OS?
Ubuntu 24.04
NuttX Version
master (cf03942d)
Issue Architecture
[Arch: all]
Issue Area
[Area: Posix]
Host information
Architecture-independent C bug in libs/libc/time/lib_strptime.c. Reproduced on Ubuntu 24.04 x86_64 with gcc 13.3.0.
Verification
- I have verified before submitting the report.
- Lenguaje dominante
- C
- Estrellas
- 4.1k
- Forks
- 1.8k
- Merge medio
- 1 d 5 h
- PR fusionados (30 d)
- 878
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una 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 apache/nuttx
-
[BUG] libc/stdlib: lib_checkbase() strips "0x" prefix in base 16 even when no hex digit followsAbiertoArch: all Area: Posix OS: Linux
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
mtd: RAM consolidation reads past its block buffer on a malformed entryPosiblemente ocupada @Ahmed55559 la tomó hace 6 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Please rerun `pre-commit run -a`AbiertoArch: all Arch: arm Area: Build system OS: Linux Type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/nuttx#19435 · 9 comentarios ·
Los mantenedores suelen responder en 1 día
-
Arch: all OS: Linux Type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
apache/nuttx#16249 · 7 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/nuttx
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
fastfetch-cli/fastfetch#2780 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
elliotchance/vsql#2079 ·
Los mantenedores suelen responder en 1 día
-
docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 61/100
vim/vim#22107 · 1 comentario ·
Los mantenedores suelen responder en 13 días
-
threadpool: a failed `pthread_cond_wait` makes Mlucas hang instead of stoppingPosiblemente ocupada @leinardi la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
primesearch/Mlucas#398 ·