]> granicus.if.org Git - file/commitdiff
PR/229: Fix not portable pointer comparison code.
authorChristos Zoulas <christos@zoulas.com>
Sun, 6 Jan 2013 20:22:16 +0000 (20:22 +0000)
committerChristos Zoulas <christos@zoulas.com>
Sun, 6 Jan 2013 20:22:16 +0000 (20:22 +0000)
src/softmagic.c

index 6dd62c4323d8fb1348fb3160d5649ee28ff341cb..97375eecc8bde9dc2420267c120b42653df2966c 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.156 2013/01/03 23:11:38 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.157 2013/01/04 16:37:54 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -1064,8 +1064,8 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
                        if (type == FILE_BESTRING16)
                                src++;
 
-                       /* check for pointer overflow */
-                       if (src < s) {
+                       /* check that offset is within range */
+                       if (offset >= nbytes) {
                                file_magerror(ms, "invalid offset %u in mcopy()",
                                    offset);
                                return -1;