From: Darik Horn Date: Tue, 15 Jan 2013 01:27:39 +0000 (-0600) Subject: Ensure that zfs diff prints unicode safely. X-Git-Tag: zfs-0.6.0-rc14~28 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38145d6;p=zfs Ensure that zfs diff prints unicode safely. In the stream_bytes() library function used by `zfs diff`, explicitly cast each byte in the input string to an unsigned character so that the Linux fprintf() correctly escapes to octal and does not mangle the output. Signed-off-by: Brian Behlendorf Closes #1172 --- diff --git a/lib/libzfs/libzfs_diff.c b/lib/libzfs/libzfs_diff.c index 8140a703a..eb05f4d5b 100644 --- a/lib/libzfs/libzfs_diff.c +++ b/lib/libzfs/libzfs_diff.c @@ -141,7 +141,7 @@ stream_bytes(FILE *fp, const char *string) if (*string > ' ' && *string != '\\' && *string < '\177') (void) fprintf(fp, "%c", *string++); else - (void) fprintf(fp, "\\%03o", *string++); + (void) fprintf(fp, "\\%03o", (unsigned char)*string++); } }