From: Christos Zoulas Date: Wed, 26 Sep 2007 20:19:05 +0000 (+0000) Subject: preserve NUL's in string16 conversions. X-Git-Tag: FILE4_22~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fec5f18613b7fc7bcfea74d32f020c471598abd7;p=file preserve NUL's in string16 conversions. --- diff --git a/src/softmagic.c b/src/softmagic.c index 6cc0c7dc..a0e709f3 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -38,7 +38,7 @@ #ifndef lint -FILE_RCSID("@(#)$File: softmagic.c,v 1.97 2007/03/25 03:13:47 christos Exp $") +FILE_RCSID("@(#)$File: softmagic.c,v 1.99 2007/05/08 14:44:18 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;