openbsd-ports/mail/smtpclient/patches/patch-smtpclient_main_c
sturm 283e9fc04c - fix handling of last lines not ending in '\n'
- fix handling of lines beginning with a '.'
- bump PKGNAME

from MAINTAINER
2003-04-01 18:52:05 +00:00

61 lines
1.8 KiB
Plaintext

$OpenBSD: patch-smtpclient_main_c,v 1.2 2003/04/01 18:52:05 sturm Exp $
--- smtpclient_main.c.orig Wed Aug 1 15:25:22 2001
+++ smtpclient_main.c Wed Aug 1 15:33:07 2001
@@ -86,7 +86,7 @@ void log(char *str, ...)
char buf[1024];
va_start(ap, str);
- vsprintf(buf, str, ap);
+ vsnprintf(buf, 1024, str, ap);
if (usesyslog)
syslog(LOG_ERR, "SMTPclient: %s", buf);
else
@@ -306,6 +306,7 @@
int s;
int r;
int i;
+ size_t ll;
struct passwd *pwd;
char *cp;
@@ -395,16 +395,16 @@ int main(int argc, char **argv)
log("%s: unknown host\n", my_name);
exit(1);
}
- strcpy(my_name, hp->h_name);
+ strlcpy(my_name, hp->h_name, sizeof(my_name));
/*
* Determine from address.
*/
if (from_addr == NULL) {
if ((pwd = getpwuid(getuid())) == 0) {
- sprintf(buf, "userid-%d@%s", getuid(), my_name);
+ snprintf(buf, (sizeof(buf) - 1), "userid-%d@%s", getuid(), my_name);
} else {
- sprintf(buf, "%s@%s", pwd->pw_name, my_name);
+ snprintf(buf, (sizeof(buf) - 1), "%s@%s", pwd->pw_name, my_name);
}
from_addr = strdup(buf);
}
@@ -496,12 +497,13 @@
toqp(stdin, sfp);
} else {
while (fgets(buf, sizeof(buf), stdin)) {
- buf[strlen(buf)-1] = 0;
- if (strcmp(buf, ".") == 0) { /* quote alone dots */
- fprintf(sfp, "..\r\n");
- } else { /* pass thru mode */
- fprintf(sfp, "%s\r\n", buf);
+ if ((ll = strlen(buf)) > 0 && buf[ll-1] == '\n') {
+ buf[ll-1] = 0;
}
+ if (buf[0] == '.') { /* quote dots */
+ fprintf(sfp, ".");
+ }
+ fprintf(sfp, "%s\r\n", buf);
}
}