commit f4e8603d28528fe54269d299aefcdc0bfa932c61
parent 5f721ec36e692243453e5d728aeb8f0710bfcfc2
Author: sin <sin@2f30.org>
Date: Sun, 3 Mar 2013 16:07:04 +0000
mdiff: Check if the user requested to read an out of bounds region
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/mdiff.c b/mdiff.c
@@ -101,6 +101,9 @@ mdiff_read_diff(int fd, struct mdiff_hdr *hdr, uint32_t region)
if (fd < 0 || !hdr)
return NULL;
+ if (region >= hdr->nregions)
+ return NULL;
+
offset = sizeof(*hdr);
ret = lseek(fd, offset, SEEK_SET);
if (ret < 0)