diff options
| author | Christos Zoulas <christos@zoulas.com> | 2004-11-21 06:09:43 +0000 |
|---|---|---|
| committer | Christos Zoulas <christos@zoulas.com> | 2004-11-21 06:09:43 +0000 |
| commit | 918abb1080bb2f3c0ad6547eed378ea90fecf2bb (patch) | |
| tree | cb408695fa0e344389ff24a9a2187aeda5806afc | |
| parent | eaf791de115cb4334d7b51466f4948da9504435b (diff) | |
| download | file-git-918abb1080bb2f3c0ad6547eed378ea90fecf2bb.tar.gz | |
Fix thinko.
| -rw-r--r-- | src/softmagic.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/softmagic.c b/src/softmagic.c index 3cc0c2cf..912215d9 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -39,7 +39,7 @@ #ifndef lint -FILE_RCSID("@(#)$Id: softmagic.c,v 1.70 2004/11/20 23:50:13 christos Exp $") +FILE_RCSID("@(#)$Id: softmagic.c,v 1.71 2004/11/21 06:09:43 christos Exp $") #endif /* lint */ private int match(struct magic_set *, struct magic *, uint32_t, @@ -647,7 +647,13 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, return 0; } - if (offset + sizeof(*p) <= nbytes) + if (offset >= nbytes) { + (void)memset(p, '\0', sizeof(*p)); + return 0; + } + if (nbytes - offset < sizeof(*p)) + nbytes = nbytes - offset; + else nbytes = sizeof(*p); (void)memcpy(p, s + offset, nbytes); @@ -657,7 +663,7 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, * might even cause problems */ if (nbytes < sizeof(*p)) - (void)memset(p + nbytes, 0, sizeof(*p) - nbytes); + (void)memset(p + nbytes, '\0', sizeof(*p) - nbytes); return 0; } |
