]> granicus.if.org Git - file/commitdiff
make sure we don't exceed the array sie if nbytes is odd. Found by oss-fuzz
authorChristos Zoulas <christos@zoulas.com>
Tue, 20 Dec 2016 03:15:16 +0000 (03:15 +0000)
committerChristos Zoulas <christos@zoulas.com>
Tue, 20 Dec 2016 03:15:16 +0000 (03:15 +0000)
src/softmagic.c

index 16e38f991bd1de2949e8dfa77be5aeb925642f29..89b6f14a9df99395c5fe205a165476b5ba84dea8 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.237 2016/10/10 20:44:15 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.238 2016/10/24 18:02:17 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -1260,7 +1260,8 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
                                if (*dst == '\0') {
                                        if (type == FILE_BESTRING16 ?
                                            *(src - 1) != '\0' :
-                                           *(src + 1) != '\0')
+                                           ((src + 1 < esrc) &&
+                                           *(src + 1) != '\0'))
                                                *dst = ' ';
                                }
                        }