]> granicus.if.org Git - zfs/commitdiff
Ensure that zfs diff prints unicode safely.
authorDarik Horn <dajhorn@vanadac.com>
Tue, 15 Jan 2013 01:27:39 +0000 (19:27 -0600)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 16 Jan 2013 18:15:57 +0000 (10:15 -0800)
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 <behlendorf1@llnl.gov>
Closes #1172

lib/libzfs/libzfs_diff.c

index 8140a703a2bb9356772c4fffed86a5505f2c44e1..eb05f4d5ba5b68814a062d99b4750aad5ac0f623 100644 (file)
@@ -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++);
        }
 }