summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak2012-04-26 09:28:44 +0200
committerKarel Zak2012-04-26 09:28:44 +0200
commitf6efe5024c9c47c0c88a928be63cc31e27c1cab3 (patch)
treee9ede430633135a4a22155c3cf8a7aedf263cbd3 /lib
parentlib/tt: encode data for RAW and EXPORT format (diff)
downloadkernel-qcow2-util-linux-f6efe5024c9c47c0c88a928be63cc31e27c1cab3.tar.gz
kernel-qcow2-util-linux-f6efe5024c9c47c0c88a928be63cc31e27c1cab3.tar.xz
kernel-qcow2-util-linux-f6efe5024c9c47c0c88a928be63cc31e27c1cab3.zip
lib/tt: check for non-printable chars for raw/export format
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/tt.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/tt.c b/lib/tt.c
index 2d5b16b52..1d69a34c4 100644
--- a/lib/tt.c
+++ b/lib/tt.c
@@ -559,8 +559,8 @@ static void fputs_quoted(const char *data, FILE *out)
fputc('"', out);
for (p = data; p && *p; p++) {
- if ((unsigned char) *p == 0x22)
- fputs("\\x22", out);
+ if ((unsigned char) *p == 0x22 || !isprint((unsigned char) *p))
+ fprintf(out, "\\x%02x", *p);
else
fputc(*p, out);
}
@@ -572,7 +572,7 @@ static void fputs_nonblank(const char *data, FILE *out)
const char *p;
for (p = data; p && *p; p++) {
- if (isblank((unsigned char) *p))
+ if (isblank((unsigned char) *p) || !isprint((unsigned char) *p))
fprintf(out, "\\x%02x", *p);
else
fputc(*p, out);