aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2019-05-12 10:08:35 +0200
committerMatthias Andree <matthias.andree@gmx.de>2019-05-12 10:12:23 +0200
commitab245dddc6a34d6dd2965bf1f74071590c553112 (patch)
tree66883e8ea7a33eaab93f5e84acb2404b41947782
parent1e3a3e7e47336ceaee07cc495c728e35f4ac9fc6 (diff)
downloadfetchmail-ab245dddc6a34d6dd2965bf1f74071590c553112.tar.gz
fetchmail-ab245dddc6a34d6dd2965bf1f74071590c553112.tar.bz2
fetchmail-ab245dddc6a34d6dd2965bf1f74071590c553112.zip
Replace most strncpy() by strlcpy() calls.
-rw-r--r--kerberos.c6
-rw-r--r--smtp.c3
-rw-r--r--socket.c2
-rw-r--r--transact.c6
4 files changed, 6 insertions, 11 deletions
diff --git a/kerberos.c b/kerberos.c
index 141c9e3a..6c8b5a0a 100644
--- a/kerberos.c
+++ b/kerberos.c
@@ -93,16 +93,14 @@ int do_rfc1731(int sock, const char *command, const char *truename)
* 32-bit number in network byte order.
*/
- strncpy(srvinst, truename, (sizeof srvinst)-1);
- srvinst[(sizeof srvinst)-1] = '\0';
+ strlcpy(srvinst, truename, sizeof srvinst);
for (p = srvinst; *p; p++) {
if (isupper((unsigned char)*p)) {
*p = tolower((unsigned char)*p);
}
}
- strncpy(srvrealm, (char *)krb_realmofhost(srvinst), (sizeof srvrealm)-1);
- srvrealm[(sizeof srvrealm)-1] = '\0';
+ strlcpy(srvrealm, (char *)krb_realmofhost(srvinst), sizeof srvrealm);
if ((p = strchr(srvinst, '.')) != NULL) {
*p = '\0';
}
diff --git a/smtp.c b/smtp.c
index e6af901b..9ca93813 100644
--- a/smtp.c
+++ b/smtp.c
@@ -204,8 +204,7 @@ int SMTP_ehlo(int sock, char smtp_mode, const char *host, char *name, char *pass
if (!strncasecmp(hp->name, smtp_response+4, strlen(hp->name))) {
*opt |= hp->value;
if (strncmp(hp->name, "AUTH ", 5) == 0)
- strncpy(auth_response, smtp_response, sizeof(auth_response));
- auth_response[sizeof(auth_response)-1] = '\0';
+ strlcpy(auth_response, smtp_response, sizeof(auth_response));
}
if ((smtp_response[0] == '1' || smtp_response[0] == '2' || smtp_response[0] == '3') && smtp_response[3] == ' ') {
if (*opt & ESMTP_AUTH)
diff --git a/socket.c b/socket.c
index 7550519b..399ba189 100644
--- a/socket.c
+++ b/socket.c
@@ -217,7 +217,7 @@ int UnixOpen(const char *path)
struct sockaddr_un ad;
memset(&ad, 0, sizeof(ad));
ad.sun_family = AF_UNIX;
- strncpy(ad.sun_path, path, sizeof(ad.sun_path)-1);
+ strlcpy(ad.sun_path, path, sizeof(ad.sun_path));
sock = socket( AF_UNIX, SOCK_STREAM, 0 );
if (sock < 0)
diff --git a/transact.c b/transact.c
index db8a4cd9..46a767eb 100644
--- a/transact.c
+++ b/transact.c
@@ -821,8 +821,7 @@ eoh:
already_has_return_path = TRUE;
if (cp[0]=='\0') /* nxtaddr() strips the brackets... */
cp=nulladdr;
- strncpy(msgblk.return_path, cp, sizeof(msgblk.return_path));
- msgblk.return_path[sizeof(msgblk.return_path)-1] = '\0';
+ strlcpy(msgblk.return_path, cp, sizeof(msgblk.return_path));
if (!ctl->mda) {
free(line);
continue;
@@ -1079,8 +1078,7 @@ process_headers:
else if (app_from_offs >= 0 && (ap = nxtaddr(msgblk.headers + app_from_offs))) {}
/* multi-line MAIL FROM addresses confuse SMTP terribly */
if (ap && !strchr(ap, '\n')) {
- strncpy(msgblk.return_path, ap, sizeof(msgblk.return_path));
- msgblk.return_path[sizeof(msgblk.return_path)-1] = '\0';
+ strlcpy(msgblk.return_path, ap, sizeof(msgblk.return_path));
}
}