From 8b081eaa55b1eb7a457f7bf43be5997a1fef3ac0 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 2 Jan 2018 16:50:57 +0000 Subject: [PATCH] Revert r326844 There has been some fallout from the change. The change itself was not valueable enough to spend time investigating the corner cases, let's just back it out. Reported by: flo --- usr.sbin/mailwrapper/Makefile | 2 ++ usr.sbin/mailwrapper/Makefile.depend | 3 ++- usr.sbin/mailwrapper/mailwrapper.c | 18 ++++++------------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/usr.sbin/mailwrapper/Makefile b/usr.sbin/mailwrapper/Makefile index 98222ae22cf..799d7e43fb7 100644 --- a/usr.sbin/mailwrapper/Makefile +++ b/usr.sbin/mailwrapper/Makefile @@ -5,6 +5,8 @@ .if ${MK_MAILWRAPPER} != "no" PROG= mailwrapper MAN= mailwrapper.8 + +LIBADD= util .endif .if ${MK_MAILWRAPPER} != "no" || ${MK_SENDMAIL} != "no" diff --git a/usr.sbin/mailwrapper/Makefile.depend b/usr.sbin/mailwrapper/Makefile.depend index 5c0ddbe76ee..991757ecadc 100644 --- a/usr.sbin/mailwrapper/Makefile.depend +++ b/usr.sbin/mailwrapper/Makefile.depend @@ -7,7 +7,8 @@ DIRDEPS = \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ - lib/libcompiler_rt + lib/libcompiler_rt \ + lib/libutil \ .include diff --git a/usr.sbin/mailwrapper/mailwrapper.c b/usr.sbin/mailwrapper/mailwrapper.c index 9b57c458b16..1ad4053a843 100644 --- a/usr.sbin/mailwrapper/mailwrapper.c +++ b/usr.sbin/mailwrapper/mailwrapper.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -88,17 +89,14 @@ int main(int argc, char *argv[], char *envp[]) { FILE *config; - char *line, *cp, *from, *to, *ap, *walk; + char *line, *cp, *from, *to, *ap; const char *progname; char localmailerconf[MAXPATHLEN]; const char *mailerconf; - size_t linecap = 0, lineno = 0; - ssize_t linelen; + size_t len, lineno = 0; int i; struct arglist al; - line = NULL; - /* change __progname to mailwrapper so we get sensible error messages */ progname = getprogname(); setprogname("mailwrapper"); @@ -125,16 +123,12 @@ main(int argc, char *argv[], char *envp[]) } for (;;) { - if ((linelen = getline(&line, &linecap, config)) <= 0) { - if (feof(config)) { + if ((line = fparseln(config, &len, &lineno, NULL, 0)) == NULL) { + if (feof(config)) errx(EX_CONFIG, "no mapping in %s", mailerconf); - } err(EX_CONFIG, "cannot parse line %lu", (u_long)lineno); } - lineno++; - walk = line; - /* strip comments */ - strsep(&walk, "#"); + #define WS " \t\n" cp = line;