mirror of
https://github.com/apache/nuttx.git
synced 2026-09-29 10:34:23 +00:00
POSIX requires getdelim()/getline() to allocate a new buffer whenever *lineptr is NULL, regardless of the value of *n. The previous code read the buffer size from *n unconditionally and only fell back to the initial size when *n was zero, so a caller that passes *lineptr == NULL together with an uninitialized (non-zero) *n caused lib_malloc() to be invoked with that garbage size and typically fail with ENOMEM. Treat a NULL *lineptr the same as a zero *n: (re)allocate from the known BUFSIZE_INIT and ignore the untrusted *n. This matches the glibc behaviour that portable code relies on (for example toybox grep, which calls getdelim() with an uninitialized size variable). Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> |
||
|---|---|---|
| .. | ||
| CMakeLists.txt | ||
| Kconfig | ||
| lib_asprintf.c | ||
| lib_clearerr.c | ||
| lib_dprintf.c | ||
| lib_fclose.c | ||
| lib_feof.c | ||
| lib_ferror.c | ||
| lib_fflush.c | ||
| lib_fgetc.c | ||
| lib_fgetpos.c | ||
| lib_fgets.c | ||
| lib_fgetwc.c | ||
| lib_fileno.c | ||
| lib_fmemopen.c | ||
| lib_fopen.c | ||
| lib_fopencookie.c | ||
| lib_fprintf.c | ||
| lib_fputc.c | ||
| lib_fputs.c | ||
| lib_fputwc.c | ||
| lib_fputws.c | ||
| lib_fread.c | ||
| lib_freopen.c | ||
| lib_fscanf.c | ||
| lib_fseek.c | ||
| lib_fseeko.c | ||
| lib_fsetpos.c | ||
| lib_ftell.c | ||
| lib_ftello.c | ||
| lib_fwrite.c | ||
| lib_getc.c | ||
| lib_getchar.c | ||
| lib_getdelim.c | ||
| lib_gets.c | ||
| lib_gets_s.c | ||
| lib_getwc.c | ||
| lib_libdgets.c | ||
| lib_libfflush.c | ||
| lib_libfgets.c | ||
| lib_libfilelock.c | ||
| lib_libflushall.c | ||
| lib_libfread_unlocked.c | ||
| lib_libfwrite.c | ||
| lib_libgetstreams.c | ||
| lib_open_memstream.c | ||
| lib_perror.c | ||
| lib_printf.c | ||
| lib_putc.c | ||
| lib_putchar.c | ||
| lib_puts.c | ||
| lib_putwc.c | ||
| lib_putwchar.c | ||
| lib_rdflush_unlocked.c | ||
| lib_remove.c | ||
| lib_renameat.c | ||
| lib_rewind.c | ||
| lib_scanf.c | ||
| lib_setbuf.c | ||
| lib_setbuffer.c | ||
| lib_setvbuf.c | ||
| lib_snprintf.c | ||
| lib_sprintf.c | ||
| lib_sscanf.c | ||
| lib_tempnam.c | ||
| lib_tmpfile.c | ||
| lib_tmpnam.c | ||
| lib_ungetc.c | ||
| lib_ungetwc.c | ||
| lib_vasprintf.c | ||
| lib_vdprintf.c | ||
| lib_vfprintf.c | ||
| lib_vfscanf.c | ||
| lib_vprintf.c | ||
| lib_vscanf.c | ||
| lib_vsnprintf.c | ||
| lib_vsprintf.c | ||
| lib_vsscanf.c | ||
| lib_wrflush_unlocked.c | ||
| Make.defs | ||