OVMS3-idf/components/console
Ivan Grokhotkov 0ed64da963 console: initialize buf_size before calling open_memstream
POSIX open_memstream documentation [1] does not mention that it may use
the  value supplied in buf_size before the call.
newlib implementation of open_memstream does use it as a hint of the
buffer size [2]. To avoid using potential garbage in this variable,
newlib caps the size to 64kB (!).

If the allocation of this initial buffer fails, NULL file pointer is
returned. Previous code did not check returned file pointer and crashed
when it was used.

Initialize size to zero (in which case newlib allocates a 64 byte
buffer), and check the returned file pointer.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/open_memstream.html
[2] https://github.com/espressif/newlib-esp32/blob/23c0f21/newlib/libc/stdio/open_memstream.c#L26-L29
    https://github.com/espressif/newlib-esp32/blob/23c0f21/newlib/libc/stdio/open_memstream.c#L324-L336
2017-08-23 01:10:30 +08:00
..
argtable3 console/argtable3: expose arg_print_formatted function 2017-08-21 15:58:28 +08:00
linenoise newlib: implement usleep 2017-08-21 15:58:28 +08:00
commands.c console: initialize buf_size before calling open_memstream 2017-08-23 01:10:30 +08:00
component.mk add console component and example 2017-08-21 15:58:27 +08:00
esp_console.h add console component and example 2017-08-21 15:58:27 +08:00
split_argv.c add console component and example 2017-08-21 15:58:27 +08:00