]> granicus.if.org Git - file/commitdiff
preserve NUL's in string16 conversions.
authorChristos Zoulas <christos@zoulas.com>
Wed, 26 Sep 2007 20:19:05 +0000 (20:19 +0000)
committerChristos Zoulas <christos@zoulas.com>
Wed, 26 Sep 2007 20:19:05 +0000 (20:19 +0000)
src/softmagic.c

index 6cc0c7dca930b4046a234d40c501e62f43d07b24..a0e709f3bdfe8ade2a18c24c67aad19c237d227b 100644 (file)
@@ -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;