[PATCH 09/17] ident.c: read /etc/mailname with strbuf_gets()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 28, 2015, 22:25 UTC
- Message-ID
- <1446071161-15610-10-git-send-email-gitster@pobox.com>
- In-Reply-To
- <1446071161-15610-1-git-send-email-gitster@pobox.com>
Just in case /etc/mailname file was edited with a DOS editor, read it with strbuf_gets() so that a stray CR is not included as the last character of the mail hostname.
We _might_ want to more aggressively discard whitespace characters around the line with strbuf_trim(), but that is a bit outside the scope of this series.
Signed-off-by: Junio C Hamano <gitster@pobox.com> --- ident.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ident.c b/ident.c index 5ff1aad..c377f2b 100644 --- a/ident.c +++ b/ident.c @@ -55,7 +55,7 @@ static int add_mailname_host(struct strbuf *buf) strerror(errno)); return -1; } - if (strbuf_getline(&mailnamebuf, mailname, '\n') == EOF) { + if (strbuf_gets(&mailnamebuf, mailname) == EOF) { if (ferror(mailname)) warning("cannot read /etc/mailname: %s", strerror(errno));
-- 2.6.2-423-g5314b62