diff options
author | YamaArashi <shadow962@live.com> | 2016-09-11 10:02:01 -0700 |
---|---|---|
committer | YamaArashi <shadow962@live.com> | 2016-09-11 10:02:01 -0700 |
commit | a1f83e332fb38b2787e7dd3d4e9488a7996730d9 (patch) | |
tree | 2841aa2510f688568f0e6ca46c6f4f0505d5c95d /tools/gbagfx/rl.c | |
parent | 5d1815d7db233ba6d697ad1f5371f0cdfb46c1b3 (diff) |
add error check to RL decompression
Diffstat (limited to 'tools/gbagfx/rl.c')
-rw-r--r-- | tools/gbagfx/rl.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/gbagfx/rl.c b/tools/gbagfx/rl.c index e90ad808b..968c9347e 100644 --- a/tools/gbagfx/rl.c +++ b/tools/gbagfx/rl.c @@ -33,6 +33,9 @@ unsigned char *RLDecompress(unsigned char *src, int srcSize, int *uncompressedSi int length = (flags & 0x7F) + 3; unsigned char data = src[srcPos++]; + if (destPos + length > destSize) + goto fail; + for (int i = 0; i < length; i++) dest[destPos++] = data; } @@ -40,6 +43,9 @@ unsigned char *RLDecompress(unsigned char *src, int srcSize, int *uncompressedSi { int length = (flags & 0x7F) + 1; + if (destPos + length > destSize) + goto fail; + for (int i = 0; i < length; i++) dest[destPos++] = src[srcPos++]; } |