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

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