1 diff -ur dialog-1.3-20160209.orig/argv.c dialog-1.3-20160209/argv.c
2 --- dialog-1.3-20160209.orig/argv.c 2015-05-13 00:34:39.000000000 +0000
3 +++ dialog-1.3-20160209/argv.c 2016-02-11 10:41:08.705828223 +0000
8 - } else if (!quoted && isspace(UCH(blob[n]))) {
10 + } else if (blob[n] == '\\') {
11 + if (quoted && !isspace(UCH(blob[n + 1]))) {
15 + *param++ = blob[n + 1];
20 + } else if (!quoted && isspace(UCH(blob[n]))) {
31 - if (blob[n] == '\\') {
33 - break; /* The string is terminated by a backslash */
38 diff -ur dialog-1.3-20160209.orig/dialog.c dialog-1.3-20160209/dialog.c
39 --- dialog-1.3-20160209.orig/dialog.c 2016-02-09 00:05:39.000000000 +0000
40 +++ dialog-1.3-20160209/dialog.c 2016-02-11 10:41:08.707828223 +0000
44 list = dlg_string_to_argv(blob);
45 - added = dlg_count_argv(list);
47 - /* *argcp arguments before the expansion of --file
48 - - 2 for the removal of '--file <filepath>'
49 - + added for the arguments contained in <filepath>
50 - + 1 for the terminating NULL pointer */
51 - size_t need = (size_t) (*argcp + added - 1);
53 - *argvp = dlg_realloc(char *, need, *argvp);
54 - assert_ptr(*argvp, "unescape_argv");
56 - char **newp = dlg_malloc(char *, need);
57 - assert_ptr(newp, "unescape_argv");
58 - for (n = 0; n < *argcp; ++n) {
59 - newp[n] = (*argvp)[n];
60 + if ((added = dlg_count_argv(list)) != 0) {
62 + size_t need = (size_t) (*argcp + added + 1);
64 + *argvp = dlg_realloc(char *, need, *argvp);
65 + assert_ptr(*argvp, "unescape_argv");
67 + char **newp = dlg_malloc(char *, need);
68 + assert_ptr(newp, "unescape_argv");
69 + for (n = 0; n < *argcp; ++n) {
70 + newp[n] = (*argvp)[n];
75 - /* The new array is not NULL-terminated yet. */
78 + dialog_opts = dlg_realloc(bool, need, dialog_opts);
79 + assert_ptr(dialog_opts, "unescape_argv");
81 - dialog_opts = dlg_realloc(bool, need, dialog_opts);
82 - assert_ptr(dialog_opts, "unescape_argv");
84 - /* Shift the arguments after '--file <filepath>'
85 - right by (added - 2) positions */
86 - for (n = *argcp - 1; n >= j + 2; --n) {
87 - (*argvp)[n + added - 2] = (*argvp)[n];
88 - dialog_opts[n + added - 2] = dialog_opts[n];
90 + for (n = *argcp; n >= j + 2; --n) {
91 + (*argvp)[n + added - 2] = (*argvp)[n];
92 + dialog_opts[n + added - 2] = dialog_opts[n];
94 + } else if (added == 1) {
95 + for (n = j; n < *argcp; ++n) {
96 + (*argvp)[n] = (*argvp)[n + 1];
97 + dialog_opts[n] = dialog_opts[n + 1];
100 - } else if (added < 2) {
101 - /* 0 or 1 argument read from the included file
102 - -> shift the arguments after '--file <filepath>'
103 - left by (2 - added) positions */
104 - for (n = j + added; n + 2 - added < *argcp; ++n) {
105 - (*argvp)[n] = (*argvp)[n + 2 - added];
106 - dialog_opts[n] = dialog_opts[n + 2 - added];
107 + for (n = 0; n < added; ++n) {
108 + (*argvp)[n + j] = list[n];
109 + dialog_opts[n + j] = FALSE;
111 + *argcp += added - 2;
113 + --j; /* force rescan */
115 - /* Copy the inserted arguments to *argvp */
116 - for (n = 0; n < added; ++n) {
117 - (*argvp)[n + j] = list[n];
118 - dialog_opts[n + j] = FALSE;
120 - *argcp += added - 2;
121 - (*argvp)[*argcp] = 0; /* Write the NULL terminator */
122 - free(list); /* No-op if 'list' is NULL */
123 - /* Force rescan starting from the first inserted argument */
127 dlg_exiterr("Cannot open --file %s", filename);
129 + (*argvp)[*argcp] = 0;
133 dlg_exiterr("No value given for --file");