[4.1] c07c58d Remove implicit line feed when using formatfile.
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Tue Jun 7 14:07:06 CEST 2016
commit c07c58d782d3e8fcd58ef28e9063cf19c10134fa
Author: Lasse Karstensen <lkarsten at varnish-software.com>
Date: Mon May 30 13:35:53 2016 +0200
Remove implicit line feed when using formatfile.
Fixes: #1967
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index 76eea41..9a2e89c 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -1104,12 +1104,14 @@ read_format(const char *formatfile)
{
FILE *fmtfile;
size_t len = 0;
+ int fmtlen;
char *fmt = NULL;
fmtfile = fopen(formatfile, "r");
if (fmtfile == NULL)
VUT_Error(1, "Can't open format file (%s)", strerror(errno));
- if (getline(&fmt, &len, fmtfile) == -1) {
+ fmtlen = getline(&fmt, &len, fmtfile);
+ if (fmtlen == -1) {
free(fmt);
if (feof(fmtfile))
VUT_Error(1, "Empty format file");
@@ -1118,6 +1120,8 @@ read_format(const char *formatfile)
strerror(errno));
}
fclose(fmtfile);
+ if (fmt[fmtlen - 1] == '\n')
+ fmt[fmtlen - 1] = '\0';
return (fmt);
}
More information about the varnish-commit
mailing list