Skip to content

printf(): Bug for float values if _printf_float is not defined #4

@m-rosenau

Description

@m-rosenau

In file "vfprintf.c", the lines 609 and following look the following way:

		if (_printf_float == NULL) {
			if (prt_data.flags & LONGDBL)
				GET_ARG (N, ap, _LONG_DOUBLE);
			else
				GET_ARG (N, ap, double);
		}
		else {
			n = _printf_float (data, &prt_data, fp, pfunc, &ap);
		}

If _printf_float is not defined (or more precisely: if it is NULL), the variable n does not have a defined value.

This will cause the printf()-type functions (vprintf(), sprintf() ...) to return an invalid value.

However, the GNU C++ standard library uses the value returned by vsnprintf() to allocate some memory. This means that the GNU C++ library will pass a bad value to the alloca() function as a consequence. On some microcontroller architectures, this may even cause the crash of the entire CPU.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions