]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/carefulputc: encode also ' and $ in fputs_quoted() output
authorKarel Zak <kzak@redhat.com>
Thu, 27 Nov 2014 12:36:09 +0000 (13:36 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 27 Nov 2014 12:36:09 +0000 (13:36 +0100)
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>
include/carefulputc.h

index c116d0a988e83cf4bad385a433a74e76b2c0372e..3a0ec5b66939f8b052f9d7a413562e1500bb861e 100644 (file)
@@ -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)) {