From e0beacfc2a6035df682f8b8e4c3efdeea730ccbf Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 1 Mar 2021 14:11:50 +0300
Subject: [PATCH] addressed RWops12to20 seek, read and write FIXMEs about too
big params:
reject size or offset values that doesn't fit into an int.
---
src/SDL12_compat.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 4f1772c..26ef802 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -4360,7 +4360,9 @@ static Sint64 SDLCALL
RWops12to20_seek(struct SDL_RWops *rwops20, Sint64 offset, int whence)
{
SDL12_RWops *rwops12 = (SDL12_RWops *) rwops20->hidden.unknown.data1;
- FIXME("fail if (offset) is too big");
+ if (offset < -2147483648 || offset > 2147483647) {
+ return SDL20_InvalidParamError("offset");
+ }
return (Sint64) rwops12->seek(rwops12, (int) offset, whence);
}
@@ -4368,7 +4370,10 @@ static size_t SDLCALL
RWops12to20_read(struct SDL_RWops *rwops20, void *ptr, size_t size, size_t maxnum)
{
SDL12_RWops *rwops12 = (SDL12_RWops *) rwops20->hidden.unknown.data1;
- FIXME("fail if (size) or (maxnum) is too big");
+ if (size > 2147483647 || maxnum > 2147483647) {
+ SDL20_InvalidParamError("size' or 'num");
+ return 0;
+ }
return (size_t) rwops12->read(rwops12, ptr, (int) size, (int) maxnum);
}
@@ -4376,7 +4381,10 @@ static size_t SDLCALL
RWops12to20_write(struct SDL_RWops *rwops20, const void *ptr, size_t size, size_t num)
{
SDL12_RWops *rwops12 = (SDL12_RWops *) rwops20->hidden.unknown.data1;
- FIXME("fail if (size) or (maxnum) is too big");
+ if (size > 2147483647 || num > 2147483647) {
+ SDL20_InvalidParamError("size' or 'num");
+ return 0;
+ }
return (size_t) rwops12->write(rwops12, ptr, (int) size, (int) num);
}