initramfs-framework: support kernel cmdline with double quotes

Submitted by Christophe GUIBOUT on Sept. 14, 2020, 6:46 a.m. | Patch ID: 176466

Details

Message ID 20200914064632.12530-1-christophe.guibout@st.com
State New
Headers show

Commit Message

Christophe GUIBOUT Sept. 14, 2020, 6:46 a.m.
It avoids init to crash when kernel cmdline contains a string with
spaces inside, like that:
dyndbg="file drivers/usb/core/hub.c +pltf"

Signed-off-by: Christophe Guibout <christophe.guibout@st.com>
---
 .../initrdscripts/initramfs-framework/init          | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Patch hide | download patch | download mbox

diff --git a/meta/recipes-core/initrdscripts/initramfs-framework/init b/meta/recipes-core/initrdscripts/initramfs-framework/init
index c71ce0ce8c..567694aff7 100755
--- a/meta/recipes-core/initrdscripts/initramfs-framework/init
+++ b/meta/recipes-core/initrdscripts/initramfs-framework/init
@@ -88,12 +88,25 @@  fi
 
 # populate bootparam environment
 for p in `cat /proc/cmdline`; do
+	if [ -n "$quoted" ]; then
+		value="$value $p"
+		if [ "`echo $p | sed -e 's/\"$//'`" != "$p" ]; then
+			eval "bootparam_${quoted}=${value}"
+			unset quoted
+		fi
+		continue
+	fi
+
 	opt=`echo $p | cut -d'=' -f1`
 	opt=`echo $opt | sed -e 'y/.-/__/'`
 	if [ "`echo $p | cut -d'=' -f1`" = "$p" ]; then
 		eval "bootparam_${opt}=true"
 	else
 		value="`echo $p | cut -d'=' -f2-`"
+		if [ "`echo $value | sed -e 's/^\"//'`" != "$value" ]; then
+			quoted=${opt}
+			continue
+		fi
 		eval "bootparam_${opt}=\"${value}\""
 	fi
 done