Blame SOURCES/e2fsprogs-1.45.6-mke2fs-Escape-double-quotes-when-parsing-mke2fs.conf.patch

e4f77d
From 6fa8edd0fde7a540b41d78e45743208c8edab0b1 Mon Sep 17 00:00:00 2001
e4f77d
From: Lukas Czerner <lczerner@redhat.com>
e4f77d
Date: Mon, 2 Nov 2020 15:26:31 +0100
e4f77d
Subject: [PATCH] mke2fs: Escape double quotes when parsing mke2fs.conf
e4f77d
e4f77d
Currently, when constructing the <default> configuration pseudo-file using
e4f77d
the profile-to-c.awk script we will just pass the double quotes as they
e4f77d
appear in the mke2fs.conf.
e4f77d
e4f77d
This is problematic, because the resulting default_profile.c will either
e4f77d
fail to compile because of syntax error, or leave the resulting
e4f77d
configuration invalid.
e4f77d
e4f77d
It can be reproduced by adding the following line somewhere into
e4f77d
mke2fs.conf configuration and forcing mke2fs to use the <default>
e4f77d
configuration by specifying nonexistent mke2fs.conf
e4f77d
e4f77d
MKE2FS_CONFIG="nonexistent" ./misc/mke2fs -T ext4 /dev/device
e4f77d
e4f77d
default_mntopts = "acl,user_xattr"
e4f77d
^ this will fail to compile
e4f77d
e4f77d
default_mntopts = ""
e4f77d
^ this will result in invalid config file
e4f77d
e4f77d
Syntax error in mke2fs config file (<default>, line #4)
e4f77d
       Unknown code prof 17
e4f77d
e4f77d
Fix it by escaping the double quotes with a backslash in
e4f77d
profile-to-c.awk script.
e4f77d
e4f77d
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
e4f77d
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e4f77d
---
e4f77d
 misc/profile-to-c.awk | 1 +
e4f77d
 1 file changed, 1 insertion(+)
e4f77d
e4f77d
diff --git a/misc/profile-to-c.awk b/misc/profile-to-c.awk
e4f77d
index f964efd6..814f7236 100644
e4f77d
--- a/misc/profile-to-c.awk
e4f77d
+++ b/misc/profile-to-c.awk
e4f77d
@@ -4,6 +4,7 @@ BEGIN {
e4f77d
 }
e4f77d
 
e4f77d
 {
e4f77d
+  gsub("\"","\\\"",$0);
e4f77d
   printf("  \"%s\\n\"\n", $0);
e4f77d
 }
e4f77d
 
e4f77d
-- 
e4f77d
2.26.3
e4f77d