dracut/0450-Strip-NUL-bytes-in-stream-before-push-in-string.patch
Dr. Werner Fink 89d7c27ed3 Accepting request 439221 from home:danimo:branches:Base:System
- Bash cannot handle binary strigns with embedded NULs. This used
  to work by accident, it no longer does starting from bash 4.4.
  Strip NULs during all comparison operations as a workaround.
  Addresses bsc989218.
  * add 0450-Strip-NUL-bytes-in-stream-before-push-in-string.patch

OBS-URL: https://build.opensuse.org/request/show/439221
OBS-URL: https://build.opensuse.org/package/show/Base:System/dracut?expand=0&rev=272
2016-11-08 15:09:17 +00:00

120 lines
6.3 KiB
Diff

From 8ebcb9c3ded888ecd5c6fc0bbf4c9f490c3cdb56 Mon Sep 17 00:00:00 2001
From: Daniel Molkentin <dmolkentin@suse.de>
Date: Tue, 1 Mar 2016 21:03:18 +0100
Subject: [PATCH] Strip NUL bytes in stream before push in string
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Based on a patch by Tomasz Paweł Gajc <tpgxyz@gmail.com>
Workaround for bsc989218, the next upstream release
fixes this properly.
---
dracut.sh | 2 +-
modules.d/50drm/module-setup.sh | 6 +++---
modules.d/90kernel-modules/module-setup.sh | 6 +++---
modules.d/90kernel-network-modules/module-setup.sh | 6 +++---
modules.d/90multipath/module-setup.sh | 6 +++---
modules.d/95iscsi/module-setup.sh | 6 +++---
6 files changed, 16 insertions(+), 16 deletions(-)
Index: dracut-044/dracut.sh
===================================================================
--- dracut-044.orig/dracut.sh
+++ dracut-044/dracut.sh
@@ -1641,7 +1641,7 @@ if [[ $do_strip = yes ]] && ! [[ $DRACUT
# strip kernel modules, but do not touch signed modules
find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \
| while read -r -d $'\0' f || [ -n "$f" ]; do
- SIG=$(tail -c 28 "$f")
+ SIG=$(tail -c 28 "$f" | tr -d '\000')
[[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; }
done | xargs -r -0 strip -g
Index: dracut-044/modules.d/50drm/module-setup.sh
===================================================================
--- dracut-044.orig/modules.d/50drm/module-setup.sh
+++ dracut-044/modules.d/50drm/module-setup.sh
@@ -24,9 +24,9 @@ installkernel() {
local _fname _fcont
while read _fname || [ -n "$_fname" ]; do
case "$_fname" in
- *.ko) _fcont="$(< $_fname)" ;;
- *.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
- *.ko.xz) _fcont="$(xz -dc $_fname)" ;;
+ *.ko) _fcont="$(cat "$_fname" | tr -cd '[:print:]')" ;;
+ *.ko.gz) _fcont="$(gzip -dc "$_fname" | tr -cd '[:print:]')" ;;
+ *.ko.xz) _fcont="$(xz -dc "$_fname" | tr -cd '[:print:]')" ;;
esac
[[ $_fcont =~ $_drm_drivers
&& ! $_fcont =~ iw_handler_get_spy ]] \
Index: dracut-044/modules.d/90kernel-modules/module-setup.sh
===================================================================
--- dracut-044.orig/modules.d/90kernel-modules/module-setup.sh
+++ dracut-044/modules.d/90kernel-modules/module-setup.sh
@@ -10,9 +10,9 @@ installkernel() {
function bmf1() {
local _f
while read _f || [ -n "$_f" ]; do case "$_f" in
- *.ko) [[ $(< $_f) =~ $_blockfuncs ]] && echo "$_f" ;;
- *.ko.gz) [[ $(gzip -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;;
- *.ko.xz) [[ $(xz -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;;
+ *.ko) [[ $(cat "$_f" | tr -cd '[:print:]') =~ $_blockfuncs ]] && echo "$_f" ;;
+ *.ko.gz) [[ $(gzip -dc <"$_f" | tr -cd '[:print:]') =~ $_blockfuncs ]] && echo "$_f" ;;
+ *.ko.xz) [[ $(xz -dc <"$_f" | tr -cd '[:print:]') =~ $_blockfuncs ]] && echo "$_f" ;;
esac
done
return 0
Index: dracut-044/modules.d/90kernel-network-modules/module-setup.sh
===================================================================
--- dracut-044.orig/modules.d/90kernel-network-modules/module-setup.sh
+++ dracut-044/modules.d/90kernel-network-modules/module-setup.sh
@@ -45,9 +45,9 @@ installkernel() {
while read _fname; do
[[ $_fname =~ $_unwanted_drivers ]] && continue
case "$_fname" in
- *.ko) _fcont="$(< $_fname)" ;;
- *.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
- *.ko.xz) _fcont="$(xz -dc $_fname)" ;;
+ *.ko) _fcont="$(cat "$_fname" | tr -cd '[:print:]')" ;;
+ *.ko.gz) _fcont="$(gzip -dc "$_fname" | tr -cd '[:print:]')" ;;
+ *.ko.xz) _fcont="$(xz -dc "$_fname" | tr -cd '[:print:]')" ;;
esac
[[ $_fcont =~ $_net_drivers
&& ! $_fcont =~ iw_handler_get_spy ]] \
Index: dracut-044/modules.d/90multipath/module-setup.sh
===================================================================
--- dracut-044.orig/modules.d/90multipath/module-setup.sh
+++ dracut-044/modules.d/90multipath/module-setup.sh
@@ -49,9 +49,9 @@ installkernel() {
local _f
while read _f || [ -n "$_f" ]; do
case "$_f" in
- *.ko) [[ $(< $_f) =~ $_funcs ]] && echo "$_f" ;;
- *.ko.gz) [[ $(gzip -dc <$_f) =~ $_funcs ]] && echo "$_f" ;;
- *.ko.xz) [[ $(xz -dc <$_f) =~ $_funcs ]] && echo "$_f" ;;
+ *.ko) [[ $(cat "$_f" | tr -cd '[:print:]') =~ $_funcs ]] && echo "$_f" ;;
+ *.ko.gz) [[ $(gzip -dc <"$_f" | tr -cd '[:print:]') =~ $_funcs ]] && echo "$_f" ;;
+ *.ko.xz) [[ $(xz -dc <"$_f" | tr -cd '[:print:]') =~ $_funcs ]] && echo "$_f" ;;
esac
done
return 0
Index: dracut-044/modules.d/95iscsi/module-setup.sh
===================================================================
--- dracut-044.orig/modules.d/95iscsi/module-setup.sh
+++ dracut-044/modules.d/95iscsi/module-setup.sh
@@ -189,9 +189,9 @@ installkernel() {
local _f
while read _f || [ -n "$_f" ]; do
case "$_f" in
- *.ko) [[ $(< $_f) =~ $_funcs ]] && echo "$_f" ;;
- *.ko.gz) [[ $(gzip -dc <$_f) =~ $_funcs ]] && echo "$_f" ;;
- *.ko.xz) [[ $(xz -dc <$_f) =~ $_funcs ]] && echo "$_f" ;;
+ *.ko) [[ $(< "$_f" | tr -cd '[:print:]') =~ $_funcs ]] && echo "$_f" ;;
+ *.ko.gz) [[ $(gzip -dc <"$_f" | tr -cd '[:print:]') =~ $_funcs ]] && echo "$_f" ;;
+ *.ko.xz) [[ $(xz -dc <"$_f" | tr -cd '[:print:]') =~ $_funcs ]] && echo "$_f" ;;
esac
done
return 0