Skip to content

Commit 50d0158

Browse files
peffgitster
authored andcommitted
imap-send: avoid buffer overflow
We format the password prompt in an 80-character static buffer. It contains the remote host and username, so it's unlikely to overflow (or be exploitable by a remote attacker), but there's no reason not to be careful and use a strbuf. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 861444f commit 50d0158

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

imap-send.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,9 +1209,10 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
12091209
goto bail;
12101210
}
12111211
if (!srvc->pass) {
1212-
char prompt[80];
1213-
sprintf(prompt, "Password (%s@%s): ", srvc->user, srvc->host);
1214-
arg = git_getpass(prompt);
1212+
struct strbuf prompt = STRBUF_INIT;
1213+
strbuf_addf(&prompt, "Password (%s@%s): ", srvc->user, srvc->host);
1214+
arg = git_getpass(prompt.buf);
1215+
strbuf_release(&prompt);
12151216
if (!arg) {
12161217
perror("getpass");
12171218
exit(1);

0 commit comments

Comments
 (0)