Skip to content

Commit

Permalink
imap-send: avoid buffer overflow
Browse files Browse the repository at this point in the history
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Dec 13, 2011
1 parent 861444f commit 50d0158
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions imap-send.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,9 +1209,10 @@ static struct store *imap_open_store(struct imap_server_conf *srvc)
goto bail;
}
if (!srvc->pass) {
char prompt[80];
sprintf(prompt, "Password (%s@%s): ", srvc->user, srvc->host);
arg = git_getpass(prompt);
struct strbuf prompt = STRBUF_INIT;
strbuf_addf(&prompt, "Password (%s@%s): ", srvc->user, srvc->host);
arg = git_getpass(prompt.buf);
strbuf_release(&prompt);
if (!arg) {
perror("getpass");
exit(1);
Expand Down

0 comments on commit 50d0158

Please sign in to comment.