From 23955f5dd00aff51e84978f78ce3b800fd5143b2 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 14 May 1997 21:48:00 +0000 Subject: Detect embedded NULs. svn path=/trunk/; revision=1006 --- driver.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'driver.c') diff --git a/driver.c b/driver.c index 44c3dabb..53e01773 100644 --- a/driver.c +++ b/driver.c @@ -446,7 +446,7 @@ char *realname; /* real name of host */ #endif /* HAVE_GETHOSTBYNAME */ char *cp; struct idlist *idp, *xmit_names; - int good_addresses, bad_addresses; + int good_addresses, bad_addresses, has_nuls; #ifdef HAVE_RES_SEARCH int no_local_matches = FALSE; #endif /* HAVE_RES_SEARCH */ @@ -454,6 +454,7 @@ char *realname; /* real name of host */ sizeticker = 0; delete_ok = TRUE; + has_nuls = FALSE; remaining = len; olderrs = ctl->errcount; @@ -506,6 +507,9 @@ char *realname; /* real name of host */ } } + if (linelen != strlen(line)) + has_nuls = TRUE; + remaining -= linelen; /* check for end of headers; don't save terminating line */ @@ -918,9 +922,9 @@ char *realname; /* real name of host */ /* write error notifications */ #ifdef HAVE_RES_SEARCH - if (no_local_matches || bad_addresses) + if (no_local_matches || has_nuls || bad_addresses) #else - if (bad_addresses) + if (has_nuls || bad_addresses) #endif /* HAVE_RES_SEARCH */ { int errlen = 0; @@ -940,14 +944,20 @@ char *realname; /* real name of host */ break; sprintf(errhd+strlen(errhd), "recipient address %s didn't match any local name", idp->id); } + } +#endif /* HAVE_RES_SEARCH */ - if (bad_addresses) + if (has_nuls) + { + if (errhd[sizeof("X-Fetchmail-Warning: ")]) strcat(errhd, "; "); + strcat(errhd, "message has embedded NULs"); } -#endif /* HAVE_RES_SEARCH */ if (bad_addresses) { + if (errhd[sizeof("X-Fetchmail-Warning: ")]) + strcat(errhd, "; "); strcat(errhd, "SMTP listener rejected local recipient addresses: "); errlen = strlen(errhd); for (idp = xmit_names; idp; idp = idp->next) @@ -963,6 +973,7 @@ char *realname; /* real name of host */ if (idp->next) strcat(errmsg, ", "); } + } if (ctl->mda && !ctl->forcecr) -- cgit v1.2.3