1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-22 05:48:01 +01:00

argh! buffer overflow fix, try 3 :P

This commit is contained in:
kojima
2002-11-08 18:00:56 +00:00
parent 811e508c84
commit 55f3cb9577

View File

@@ -49,8 +49,18 @@ RCreateImage(unsigned width, unsigned height, int alpha)
/* detect overflow (gr33tz to ruda :D) */ /* detect overflow (gr33tz to ruda :D) */
bla1 = width*height; bla1 = width*height;
if (bla1 / height != width) {
RErrorCode = RERR_NOMEMORY;
return NULL;
}
bla2 = bla1*4; bla2 = bla1*4;
if (bla1/height != width || bla2/4 != bla1 || bla2 > INT_MAX-32) { if (bla2/4 != bla1) {
RErrorCode = RERR_NOMEMORY;
return NULL;
}
if (bla2 > INT_MAX - 4) {
RErrorCode = RERR_NOMEMORY; RErrorCode = RERR_NOMEMORY;
return NULL; return NULL;
} }
@@ -78,6 +88,7 @@ RCreateImage(unsigned width, unsigned height, int alpha)
} }
return image; return image;
} }