]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
unescape quoted strings which will be passed to exec()
authorAlan T. DeKok <aland@freeradius.org>
Thu, 30 Apr 2020 01:21:14 +0000 (21:21 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 30 Apr 2020 02:07:31 +0000 (22:07 -0400)
src/lib/util/value.c

index 7acc39ff893c1f9332a57421c10007e1ab1b736b..12d5691d837ffb35dc11f500111c5edb89d3bde9 100644 (file)
@@ -4911,6 +4911,20 @@ int fr_value_box_list_flatten_argv(TALLOC_CTX *ctx, char ***argv_p, fr_value_box
                     in_p = in_p->next) {
                        argv[i] = fr_value_box_asprint(ctx, in_p->vb_group, 0);
 
+                       /*
+                        *      Unescape quoted strings, so that the
+                        *      programs get passed the unquoted
+                        *      results.
+                        */
+                       if ((*argv[i] == '"') || (*argv[i] == '\'')) {
+                               size_t inlen, outlen;
+
+                               inlen = talloc_array_length(argv[i]) - 3;
+                               outlen = fr_value_str_unescape((uint8_t *) argv[i], argv[i] + 1, inlen, *argv[i]);
+                               fr_assert(outlen <= inlen);
+                               argv[i][outlen] = '\0';
+                       }
+
                        i++;
                }
        }