format-truncation

Jonathan Wakely jwakely.gcc@gmail.com
Thu Feb 14 10:19:00 GMT 2019


On Thu, 14 Feb 2019 at 10:11, Kalamatee <kalamatee@gmail.com> wrote:
>
> Hello
>
> I am having trouble identifying how to fix the following error we encounter
> when compiling AROS using our patched gcc 8.2.
>
> Compile failed: ccache
> /home/nick/builds/pc-x86_64-smp-gcc8/bin/linux-x86_64/tools/crosstools/x86_64-aros-gcc
> -iquote
> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/components/utilities/
> -iquote /mnt/c/Users/kalam/AROS/svn-repo/AROS/arch/all-pc/acpica -iquote .
> -mcmodel=large -mno-red-zone -mno-ms-bitfields -O2
> -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -Wall -Werror
> -Wno-pointer-sign -Wno-parentheses -Wno-strict-aliasing
> -I/home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/AROS/Developer/include/acpica
> -iquote
> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/include
> -iquote
> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/include/platform
> -DAROS_BUILD_TYPE=AROS_BUILD_TYPE_PERSONAL
> -I/home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/gen/arch/all-pc/acpica/acpica/include
> -include
> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/gen/arch/all-pc/acpica/acpica/include/acpica_deflibdefs.h
> -D__SRCFILENAME__="bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/components/utilities/utprint.c"
> -c
> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/components/utilities/utprint.c
> -o
> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/gen/arch/all-pc/acpica/acpica/utprint.o
> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/components/utilities/utprint.c:
> In function 'sprintf':
> /home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/Ports/acpica/acpica-unix-20190108/source/components/utilities/utprint.c:880:14:
> error: specified bound 4294967295 exceeds 'INT_MAX'
> [-Werror=format-truncation=]
>      Length = vsnprintf (String, ACPI_UINT32_MAX, Format, Args);
>               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> mmakefile:918: recipe for target
> '/home/nick/builds/pc-x86_64-smp-gcc8/bin/pc-x86_64-smp/gen/arch/all-pc/acpica/acpica/utprint.o'
> failed
>
> My problem is I cannot see where it is getting "INT_MAX" from as the bounds
> for the 2nd parameter.
>
> The documentation for vsnprintf says "If the *maxlen* value is 0, no
> characters are written, and *vsnprintf* returns 0. If the value is greater
> than *INT_MAX* , then *vsnprintf* behaves identically to *vsprintf* in that

Isn't that where it's coming from?

The warning is telling you that the output could be unchecked, e.g. if
it writes UINT32_MAX+1 then it would overflow your buffer.



More information about the Gcc-help mailing list