diff options
author | Sam Lantinga <slouken@libsdl.org> | 2017-09-09 08:36:37 -0700 |
---|---|---|
committer | Sam Lantinga <slouken@libsdl.org> | 2017-09-09 08:36:37 -0700 |
commit | 7499ce7aab97c0d6aa5c292d509d6afe7eaefe65 (patch) | |
tree | bc28dff62898d957364a49be7d99ddcac00d1e70 /include/SDL_config.h.cmake | |
parent | 93cddd754eb8241d7e0fdbec8717256c843318bf (diff) | |
download | sdl-7499ce7aab97c0d6aa5c292d509d6afe7eaefe65.tar.gz |
Fixed bug 3760 - RWops doesn't check for integer overflow when stdio_fseek only supports 32 bits
Simon Hug
When RWops seeks with fseek or fseeko it uses the types long or off_t which can be 32 bits on some platforms. stdio_seek does not check if the 64-bit integer for the offset fits into a 32-bit integer. Offsets equal or larger than 2 GiB will have implementation-defined behavior and failure states would be very confusing to debug.
The attached patch adds range checking by using the macros from limits.h for long type and some bit shifting for off_t because POSIX couldn't be bothered to specify min and max macros.
It also defines HAVE_FSEEKI64 in SDL_config_windows.h so that the Windows function gets picked up automatically with the default config.
And there's an additional error message for when ftell fails.
Diffstat (limited to 'include/SDL_config.h.cmake')
-rw-r--r-- | include/SDL_config.h.cmake | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index 915d51298..9befa422f 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -52,24 +52,25 @@ #if HAVE_LIBC /* Useful headers */ -#cmakedefine HAVE_ALLOCA_H 1 -#cmakedefine HAVE_SYS_TYPES_H 1 -#cmakedefine HAVE_STDIO_H 1 #cmakedefine STDC_HEADERS 1 -#cmakedefine HAVE_STDLIB_H 1 -#cmakedefine HAVE_STDARG_H 1 -#cmakedefine HAVE_MALLOC_H 1 -#cmakedefine HAVE_MEMORY_H 1 -#cmakedefine HAVE_STRING_H 1 -#cmakedefine HAVE_STRINGS_H 1 -#cmakedefine HAVE_WCHAR_H 1 -#cmakedefine HAVE_INTTYPES_H 1 -#cmakedefine HAVE_STDINT_H 1 +#cmakedefine HAVE_ALLOCA_H 1 #cmakedefine HAVE_CTYPE_H 1 -#cmakedefine HAVE_MATH_H 1 #cmakedefine HAVE_FLOAT_H 1 #cmakedefine HAVE_ICONV_H 1 +#cmakedefine HAVE_INTTYPES_H 1 +#cmakedefine HAVE_LIMITS_H 1 +#cmakedefine HAVE_MALLOC_H 1 +#cmakedefine HAVE_MATH_H 1 +#cmakedefine HAVE_MEMORY_H 1 #cmakedefine HAVE_SIGNAL_H 1 +#cmakedefine HAVE_STDARG_H 1 +#cmakedefine HAVE_STDINT_H 1 +#cmakedefine HAVE_STDIO_H 1 +#cmakedefine HAVE_STDLIB_H 1 +#cmakedefine HAVE_STRINGS_H 1 +#cmakedefine HAVE_STRING_H 1 +#cmakedefine HAVE_SYS_TYPES_H 1 +#cmakedefine HAVE_WCHAR_H 1 #cmakedefine HAVE_PTHREAD_NP_H 1 /* C library functions */ |