]> Shamusworld >> Repos - rmac/commitdiff
Fix for bug #187 - add more strict checks for .incbin sizes
authorggn <ggn@atari.org>
Sat, 14 Aug 2021 15:11:17 +0000 (18:11 +0300)
committerShamus Hammons <jlhamm@acm.org>
Fri, 20 Aug 2021 15:11:50 +0000 (10:11 -0500)
direct.c

index 607ad7c05926174d6ec20937c0ac345da09ef44b..e3685d1c8eef7c245370338c30347b215c6f4994 100644 (file)
--- a/direct.c
+++ b/direct.c
@@ -622,6 +622,10 @@ allright:
                                        close(fd);
                                        return ERROR;
                                }
+                               if ((int64_t)size <= 0)
+                               {
+                                       return error("invalid incbin size requested");
+                               }
                        }
                        else
                                size = lseek(fd, 0L, SEEK_END);
@@ -642,6 +646,10 @@ allright:
 
                                        lseek(fd, pos, SEEK_SET);
                                        size -= pos;
+                                       if ((int64_t)size < 0)
+                                       {
+                                               return error("requested incbin size out of range");
+                                       }
                                }
                                else
                                {