From: Marcin Krol Date: Thu, 11 Feb 2016 10:48:02 +0000 (+0000) Subject: - revert escaping changes, breaks existing code X-Git-Url: https://git.tld-linux.org/?a=commitdiff_plain;h=b84d13e38bd45bb262e3e07c73a637f4982b8795;p=packages%2Fdialog.git - revert escaping changes, breaks existing code --- diff --git a/dialog.spec b/dialog.spec index 0686bc0..681af3e 100644 --- a/dialog.spec +++ b/dialog.spec @@ -7,7 +7,7 @@ Summary(pl.UTF-8): Dialog tworzy okienkowy interfejs użytkownika na terminalu t Summary(tr.UTF-8): tty diyalog kutuları oluşturan bir program Name: dialog Version: %{ver}.%{sdate} -Release: 1 +Release: 2 Epoch: 1 License: LGPL v2.1 Group: Applications/Terminal @@ -15,6 +15,7 @@ Source0: ftp://invisible-island.net/dialog/%{name}-%{ver}-%{sdate}.tgz # Source0-md5: c60823a4b09e12f8ae79036f05885ba4 Source1: http://www.mif.pg.gda.pl/homepages/ankry/man-PLD/%{name}-non-english-man-pages.tar.bz2 # Source1-md5: 932081790cd8aa857822bd2b0eafa5bb +Patch0: escaping_fix.patch URL: http://invisible-island.net/dialog/dialog.html BuildRequires: gettext-devel BuildRequires: libtool @@ -81,6 +82,7 @@ Statyczna biblioteka dialog. %prep %setup -q -n %{name}-%{ver}-%{sdate} +%patch -p1 %build %configure \ diff --git a/escaping_fix.patch b/escaping_fix.patch new file mode 100644 index 0000000..2dffd8c --- /dev/null +++ b/escaping_fix.patch @@ -0,0 +1,134 @@ +diff -ur dialog-1.3-20160209.orig/argv.c dialog-1.3-20160209/argv.c +--- dialog-1.3-20160209.orig/argv.c 2015-05-13 00:34:39.000000000 +0000 ++++ dialog-1.3-20160209/argv.c 2016-02-11 10:41:08.705828223 +0000 +@@ -55,12 +55,18 @@ + ++count; + inparm = TRUE; + } +- } else if (!quoted && isspace(UCH(blob[n]))) { +- if (inparm) { ++ } else if (blob[n] == '\\') { ++ if (quoted && !isspace(UCH(blob[n + 1]))) { + if (pass) { +- *param++ = '\0'; ++ *param++ = blob[n]; ++ *param++ = blob[n + 1]; + } +- inparm = FALSE; ++ } ++ ++n; ++ } else if (!quoted && isspace(UCH(blob[n]))) { ++ inparm = FALSE; ++ if (pass) { ++ *param++ = '\0'; + } + } else { + if (!inparm) { +@@ -69,10 +75,6 @@ + ++count; + inparm = TRUE; + } +- if (blob[n] == '\\') { +- if (++n == length) +- break; /* The string is terminated by a backslash */ +- } + if (pass) { + *param++ = blob[n]; + } +diff -ur dialog-1.3-20160209.orig/dialog.c dialog-1.3-20160209/dialog.c +--- dialog-1.3-20160209.orig/dialog.c 2016-02-09 00:05:39.000000000 +0000 ++++ dialog-1.3-20160209/dialog.c 2016-02-11 10:41:08.707828223 +0000 +@@ -421,58 +421,49 @@ + blob[length] = '\0'; + + list = dlg_string_to_argv(blob); +- added = dlg_count_argv(list); +- if (added > 2) { +- /* *argcp arguments before the expansion of --file +- - 2 for the removal of '--file ' +- + added for the arguments contained in +- + 1 for the terminating NULL pointer */ +- size_t need = (size_t) (*argcp + added - 1); +- if (doalloc) { +- *argvp = dlg_realloc(char *, need, *argvp); +- assert_ptr(*argvp, "unescape_argv"); +- } else { +- char **newp = dlg_malloc(char *, need); +- assert_ptr(newp, "unescape_argv"); +- for (n = 0; n < *argcp; ++n) { +- newp[n] = (*argvp)[n]; ++ if ((added = dlg_count_argv(list)) != 0) { ++ if (added > 2) { ++ size_t need = (size_t) (*argcp + added + 1); ++ if (doalloc) { ++ *argvp = dlg_realloc(char *, need, *argvp); ++ assert_ptr(*argvp, "unescape_argv"); ++ } else { ++ char **newp = dlg_malloc(char *, need); ++ assert_ptr(newp, "unescape_argv"); ++ for (n = 0; n < *argcp; ++n) { ++ newp[n] = (*argvp)[n]; ++ } ++ *argvp = newp; ++ doalloc = TRUE; + } +- /* The new array is not NULL-terminated yet. */ +- *argvp = newp; +- doalloc = TRUE; ++ dialog_opts = dlg_realloc(bool, need, dialog_opts); ++ assert_ptr(dialog_opts, "unescape_argv"); + } +- dialog_opts = dlg_realloc(bool, need, dialog_opts); +- assert_ptr(dialog_opts, "unescape_argv"); +- +- /* Shift the arguments after '--file ' +- right by (added - 2) positions */ +- for (n = *argcp - 1; n >= j + 2; --n) { +- (*argvp)[n + added - 2] = (*argvp)[n]; +- dialog_opts[n + added - 2] = dialog_opts[n]; ++ if (added > 2) { ++ for (n = *argcp; n >= j + 2; --n) { ++ (*argvp)[n + added - 2] = (*argvp)[n]; ++ dialog_opts[n + added - 2] = dialog_opts[n]; ++ } ++ } else if (added == 1) { ++ for (n = j; n < *argcp; ++n) { ++ (*argvp)[n] = (*argvp)[n + 1]; ++ dialog_opts[n] = dialog_opts[n + 1]; ++ } + } +- } else if (added < 2) { +- /* 0 or 1 argument read from the included file +- -> shift the arguments after '--file ' +- left by (2 - added) positions */ +- for (n = j + added; n + 2 - added < *argcp; ++n) { +- (*argvp)[n] = (*argvp)[n + 2 - added]; +- dialog_opts[n] = dialog_opts[n + 2 - added]; ++ for (n = 0; n < added; ++n) { ++ (*argvp)[n + j] = list[n]; ++ dialog_opts[n + j] = FALSE; + } ++ *argcp += added - 2; ++ free(list); ++ --j; /* force rescan */ + } +- /* Copy the inserted arguments to *argvp */ +- for (n = 0; n < added; ++n) { +- (*argvp)[n + j] = list[n]; +- dialog_opts[n + j] = FALSE; +- } +- *argcp += added - 2; +- (*argvp)[*argcp] = 0; /* Write the NULL terminator */ +- free(list); /* No-op if 'list' is NULL */ +- /* Force rescan starting from the first inserted argument */ +- --j; +- continue; + } else { + dlg_exiterr("Cannot open --file %s", filename); + } ++ (*argvp)[*argcp] = 0; ++ ++j; ++ continue; + } else { + dlg_exiterr("No value given for --file"); + }