]> 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 5565f3281168b307b0be7767871d2fca13aa1be8..3e550a06a33ef075d68595b47c2170ef003d4b23 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.157 2013/01/04 16:37:54 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.158 2013/01/06 20:22:16 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;