summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos Zoulas <christos@zoulas.com>2016-12-20 03:15:16 +0000
committerChristos Zoulas <christos@zoulas.com>2016-12-20 03:15:16 +0000
commitf132b8257100877dcabdcef10051adccbc33d6f9 (patch)
tree2bba7e9cd76564e8b97b88f360ff6669f695c463
parent2d6b0edf8a76aa889abf1f8f287a4aae8578ed7d (diff)
downloadfile-git-f132b8257100877dcabdcef10051adccbc33d6f9.tar.gz
make sure we don't exceed the array sie if nbytes is odd. Found by oss-fuzz
-rw-r--r--src/softmagic.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/softmagic.c b/src/softmagic.c
index 0e9d433d..2543dfec 100644
--- a/src/softmagic.c
+++ b/src/softmagic.c
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.238 2016/10/24 18:02:17 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.239 2016/12/20 03:15:16 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 = ' ';
}
}