debian: apply security fixes from 2.24.1
[git/debian.git] / debian / patches / 0020-quote-stress-test-accept-arguments-to-test-via-the-co.diff
blob8099f0f1b4e3f68378463b0719632188e197b6af
1 From 8622e68ae556eaf2aeed312b6e33266cf638462f Mon Sep 17 00:00:00 2001
2 From: Johannes Schindelin <johannes.schindelin@gmx.de>
3 Date: Fri, 20 Sep 2019 19:09:39 +0200
4 Subject: quote-stress-test: accept arguments to test via the command-line
6 When the stress test reported a problem with quoting certain arguments,
7 it is helpful to have a facility to play with those arguments in order
8 to find out whether variations of those arguments are affected, too.
10 Let's allow `test-run-command quote-stress-test -- <args>` to be used
11 for that purpose.
13 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
14 (cherry picked from commit 55953c77c0bfcb727ffd7e293e4661b7a24b791b)
15 Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
16 ---
17 t/helper/test-run-command.c | 31 ++++++++++++++++++++-----------
18 1 file changed, 20 insertions(+), 11 deletions(-)
20 diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c
21 index 8aad4fbd42..d8e622704c 100644
22 --- a/t/helper/test-run-command.c
23 +++ b/t/helper/test-run-command.c
24 @@ -234,25 +234,34 @@ static int quote_stress_test(int argc, const char **argv)
26 for (i = 0; i < trials; i++) {
27 struct child_process cp = CHILD_PROCESS_INIT;
28 - size_t arg_count = 1 + (my_random() % 5), arg_offset;
29 + size_t arg_count, arg_offset;
30 int ret = 0;
32 argv_array_clear(&args);
33 argv_array_pushl(&args, "test-tool", "run-command",
34 "quote-echo", NULL);
35 arg_offset = args.argc;
36 - for (j = 0; j < arg_count; j++) {
37 - char buf[20];
38 - size_t min_len = 1;
39 - size_t arg_len = min_len +
40 - (my_random() % (ARRAY_SIZE(buf) - min_len));
42 - for (k = 0; k < arg_len; k++)
43 - buf[k] = special[my_random() %
44 - ARRAY_SIZE(special)];
45 - buf[arg_len] = '\0';
46 + if (argc > 0) {
47 + trials = 1;
48 + arg_count = argc;
49 + for (j = 0; j < arg_count; j++)
50 + argv_array_push(&args, argv[j]);
51 + } else {
52 + arg_count = 1 + (my_random() % 5);
53 + for (j = 0; j < arg_count; j++) {
54 + char buf[20];
55 + size_t min_len = 1;
56 + size_t arg_len = min_len +
57 + (my_random() % (ARRAY_SIZE(buf) - min_len));
59 - argv_array_push(&args, buf);
60 + for (k = 0; k < arg_len; k++)
61 + buf[k] = special[my_random() %
62 + ARRAY_SIZE(special)];
63 + buf[arg_len] = '\0';
65 + argv_array_push(&args, buf);
66 + }
69 cp.argv = args.argv;
70 --
71 2.24.0.393.g34dc348eaf