sequencer: assign only free()able strings to gpg_sign
The gpg_sign member of the replay_opts structure is of type `char *`, meaning that the sequencer deems the string to which gpg_sign points to be under its custody, i.e. it needs to be free()d by the sequencer. Therefore, let's only assign malloc()ed buffers to it. Reported-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Dec 22, 2017 at 12:50 UTC
ed1e52822ea4a8493855d9b8be1049d561946137
2 files changed
+11
-1
sequencer.c
+1
-1
@@ -160,7 +160,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
160
}
161
162
if (!strcmp(k, "commit.gpgsign")) {
163
- opts->gpg_sign = git_config_bool(k, v) ? "" : NULL;
163
+ opts->gpg_sign = git_config_bool(k, v) ? xstrdup("") : NULL;
164
return 0;
165
}
166
t/t3404-rebase-interactive.sh
+10
@@ -1318,6 +1318,16 @@ test_expect_success 'editor saves as CR/LF' '
1318
1319
SQ="'"
1320
test_expect_success 'rebase -i --gpg-sign=<key-id>' '
1321
+ test_when_finished "test_might_fail git rebase --abort" &&
1322
+ set_fake_editor &&
1323
+ FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \
1324
+ >out 2>err &&
1325
+ test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
1326
+'
1327
+
1328
+test_expect_success 'rebase -i --gpg-sign=<key-id> overrides commit.gpgSign' '
1329
+ test_when_finished "test_might_fail git rebase --abort" &&
1330
+ test_config commit.gpgsign true &&
1331
set_fake_editor &&
1332
FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \
1333
>out 2>err &&