From: Christos Zoulas Date: Wed, 26 Sep 2007 20:19:05 +0000 (+0000) Subject: preserve NUL's in string16 conversions. X-Git-Tag: FILE5_05~595 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9782366359ffb1e1b66a4050d487693a419bf266;p=file preserve NUL's in string16 conversions. --- diff --git a/src/softmagic.c b/src/softmagic.c index e37517cc..e74f09f2 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -38,7 +38,7 @@ #ifndef lint -FILE_RCSID("@(#)$File: softmagic.c,v 1.99 2007/05/08 14:44:18 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.100 2007/09/26 20:19:05 christos Exp $") #endif /* lint */ private int match(struct magic_set *, struct magic *, uint32_t, @@ -730,13 +730,17 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir, offset); return -1; } - for (/*EMPTY*/; src < esrc; src++, dst++) { + for (/*EMPTY*/; src < esrc; src += 2, dst++) { if (dst < edst) - *dst = *src++; + *dst = *src; else break; - if (*dst == '\0') - *dst = ' '; + if (*dst == '\0') { + if (type == FILE_BESTRING16 ? + *(src - 1) != '\0' : + *(src + 1) != '\0') + *dst = ' '; + } } *edst = '\0'; return 0;