Package: dphys-config
Version: 20130301~current-1
Severity: normal
Tags: patch

dphys-config fails on files with the "#@dphys-config-preprocess
backtick" preprocessor directive if the output of the command inside the
backtick contains again backticks. (This is independent of the number of
times the backtick preprocessor is called with
"#@dphys-config-preprocess".

The following patch fixes this issue:

--- /usr/bin/dphys-config       2013-12-05 01:55:37.000000000 +0100
+++ ../dphys-config     2015-03-11 14:39:38.149909422 +0100
@@ -647,20 +647,24 @@
           ${CMD_VERBOSE_PRINT} "preprocessing for backtick ..."
           ${CMD_DEBUG_SLEEP}
           local LINE
+          local REMAINDER
+          local ALREADYPARSED
           # IFS= to avoid read doing separator processing (mangles spaces)
           #   and -r to prevent \ interpretation (mangles line contents)
           cat "${WORK}" | while IFS= read -r LINE ; do
-
+            ALREADYPARSED=''
+            REMAINDER="${LINE}"
+
             # syntax taken from the shell backtick, which is also used here
             #   may have multiple substitutions on one line, so use while loop
-            while echo "${LINE}" | grep -q '`' ; do
+            while echo "${REMAINDER}" | grep -q '`' ; do
               # the '\` here need the \ because of the `` subshell
               local FRONT
-              FRONT="`echo "${LINE}" | cut -f 1  -d '\`' `"
+              FRONT="`echo "${REMAINDER}" | cut -f 1  -d '\`' `"
               local TICK
-              TICK="`echo "${LINE}"  | cut -f 2  -d '\`' `"
+              TICK="`echo "${REMAINDER}"  | cut -f 2  -d '\`' `"
               local REST
-              REST="`echo "${LINE}"  | cut -f 3- -d '\`' `"
+              REST="`echo "${REMAINDER}"  | cut -f 3- -d '\`' `"
 
               # prevent non zero return from user given command from killing us
               set +e
@@ -673,8 +677,10 @@
                 ${CMD_LOG_WARNING} "backtick returned non zero: ${RETVAL}"
               fi
 
-              LINE="${FRONT}${SUBST}${REST}"
+              REMAINDER="${REST}"
+              ALREADYPARSED="${ALREADYPARSED}${FRONT}${SUBST}"
             done
+            LINE="${ALREADYPARSED}${REMAINDER}"
             echo "${LINE}" >> "${WORK}.temp"
 
           done

The other two preprocessor directives are not affected. They cannot
appear more than once per line and hence didn't have issues to
distinguish between yet to be parsed parts of the line and output from
already parsed parts of the line.

I've already forwarded the issue and patch to upstream. This bug report
is primarily to document the issue publically.

-- System Information:
Debian Release: 8.0
  APT prefers testing-updates
  APT policy: (500, 'testing-updates'), (500, 'testing-proposed-updates'), 
(500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages dphys-config depends on:
ii  dash  0.5.7-4+b1
ii  wget  1.16-1

dphys-config recommends no packages.

Versions of packages dphys-config suggests:
ii  pciutils  1:3.2.1-3

-- no debconf information


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to