From: Karel Zak Date: Thu, 27 Nov 2014 12:36:09 +0000 (+0100) Subject: include/carefulputc: encode also ' and $ in fputs_quoted() output X-Git-Tag: v2.26-rc1~160 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cca51b9e45460e05bf5da81be80a26a70a120704;p=thirdparty%2Futil-linux.git 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 --- diff --git a/include/carefulputc.h b/include/carefulputc.h index c116d0a988..3a0ec5b669 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)) {