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.
This commit is contained in:
parent
125d8f59fc
commit
f465f24d73
14 changed files with 139 additions and 86 deletions
|
@ -37,17 +37,18 @@
|
|||
#endif
|
||||
|
||||
/* Useful headers */
|
||||
#define HAVE_ALLOCA_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define STDC_HEADERS 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_ALLOCA_H 1
|
||||
#define HAVE_CTYPE_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#define HAVE_FLOAT_H 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
#define HAVE_LIMITS_H 1
|
||||
#define HAVE_MATH_H 1
|
||||
#define HAVE_SIGNAL_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_STDIO_H 1
|
||||
#define HAVE_STRING_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* C library functions */
|
||||
#define HAVE_MALLOC 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue