Blame SOURCES/file-5.11-offset-oob.patch

89be67
diff --git a/src/softmagic.c b/src/softmagic.c
89be67
index 8d08cad..6dc86f5 100644
89be67
--- a/src/softmagic.c
89be67
+++ b/src/softmagic.c
89be67
@@ -41,8 +41,6 @@ FILE_RCSID("@(#)$File: softmagic.c,v 1.147 2011/11/05 15:44:22 rrt Exp $")
89be67
 #include <stdlib.h>
89be67
 #include <time.h>
89be67
 
89be67
-#define OFFSET_OOB(n, o, i)  ((n) < (o) || (i) >= ((n) - (o)))
89be67
-
89be67
 private int match(struct magic_set *, struct magic *, uint32_t,
89be67
     const unsigned char *, size_t, int, int, int);
89be67
 private int mget(struct magic_set *, const unsigned char *,
89be67
@@ -1601,7 +1599,7 @@ mget(struct magic_set *ms, const unsigned char *s,
89be67
 		break;
89be67
 
89be67
 	case FILE_REGEX:
89be67
-		if (OFFSET_OOB(nbytes, offset, 0))
89be67
+		if (nbytes < offset)
89be67
 			return 0;
89be67
 		break;
89be67
 
89be67
@@ -1611,7 +1609,7 @@ mget(struct magic_set *ms, const unsigned char *s,
89be67
 			return -1;
89be67
 		if (offset == 0)
89be67
 			return 0;
89be67
-		if (OFFSET_OOB(nbytes, offset, 0))
89be67
+		if (nbytes < offset)
89be67
  			return 0;
89be67
 		return file_softmagic(ms, s + offset, nbytes - offset,
89be67
 		    recursion_level, BINTEST, text);