summaryrefslogtreecommitdiffstats
path: root/include/carefulputc.h
diff options
context:
space:
mode:
authorKarel Zak2014-11-27 13:36:09 +0100
committerKarel Zak2014-11-27 13:36:09 +0100
commitcca51b9e45460e05bf5da81be80a26a70a120704 (patch)
treefbd3630cb9ba4097ee4f50b79df8ba588153ea1c /include/carefulputc.h
parentlibfdisk: add API docs (diff)
downloadkernel-qcow2-util-linux-cca51b9e45460e05bf5da81be80a26a70a120704.tar.gz
kernel-qcow2-util-linux-cca51b9e45460e05bf5da81be80a26a70a120704.tar.xz
kernel-qcow2-util-linux-cca51b9e45460e05bf5da81be80a26a70a120704.zip
include/carefulputc: encode also ' and $ in fputs_quoted() output
This change is important for commands linked with libsmartcols (e.g. lsblk(1)) to make it more safe for crazy scenarios like eval $(lsblk --fs --pairs /dev/sdb1) where the command returns NAME="value" from filesystem LABELS (etc.) Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/carefulputc.h')
-rw-r--r--include/carefulputc.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/carefulputc.h b/include/carefulputc.h
index c116d0a98..3a0ec5b66 100644
--- a/include/carefulputc.h
+++ b/include/carefulputc.h
@@ -34,6 +34,8 @@ static inline void fputs_quoted(const char *data, FILE *out)
for (p = data; p && *p; p++) {
if ((unsigned char) *p == 0x22 || /* " */
(unsigned char) *p == 0x5c || /* \ */
+ (unsigned char) *p == 0x60 || /* ` */
+ (unsigned char) *p == 0x24 || /* $ */
!isprint((unsigned char) *p) ||
iscntrl((unsigned char) *p)) {