ソースを参照

libdpkg: Trim whitespace from the end of config file lines

This will stop passing strange spaces to the option handlers, and avoids
an unintelligible error message about unbalanced quotes when using quoted
arguments.

Ref: #762031
Reported-by: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Guillem Jover 11 年 前
コミット
76bfda78aa
共有2 個のファイルを変更した8 個の追加4 個の削除を含む
  1. 2 0
      debian/changelog
  2. 6 4
      lib/dpkg/options.c

+ 2 - 0
debian/changelog

@@ -64,6 +64,8 @@ dpkg (1.18.0) UNRELEASED; urgency=low
     Closes: #776551
   * Move dpkg-divert, dpkg-statoverride and update-alternatives man pages
     from section 8 to 1, to match their installation path.
+  * Trim end of line whitespace from dpkg and dselect config file parsers.
+    Reported by Christoph Biedl <debian.axhn@manchmal.in-ulm.de>.
 
   [ Updated manpages translations ]
   * German (Helge Kreutzmann).

+ 6 - 4
lib/dpkg/options.c

@@ -87,11 +87,13 @@ dpkg_options_load_file(const char *fn, const struct cmdinfo *cmdinfos)
 
     line_num++;
 
-    if ((linebuf[0] == '#') || (linebuf[0] == '\n') || (linebuf[0] == '\0'))
+    l = strlen(linebuf);
+    while (l && c_isspace(linebuf[l - 1]))
+      l--;
+    linebuf[l] = '\0';
+
+    if ((linebuf[0] == '#') || (linebuf[0] == '\0'))
       continue;
-    l=strlen(linebuf);
-    if (linebuf[l - 1] == '\n')
-      linebuf[l - 1] = '\0';
     for (opt = linebuf; c_isalnum(*opt) || *opt == '-'; opt++) ;
     if (*opt == '\0')
       opt=NULL;