diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2019-05-12 10:08:35 +0200 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2019-05-12 10:12:23 +0200 |
commit | ab245dddc6a34d6dd2965bf1f74071590c553112 (patch) | |
tree | 66883e8ea7a33eaab93f5e84acb2404b41947782 | |
parent | 1e3a3e7e47336ceaee07cc495c728e35f4ac9fc6 (diff) | |
download | fetchmail-ab245dddc6a34d6dd2965bf1f74071590c553112.tar.gz fetchmail-ab245dddc6a34d6dd2965bf1f74071590c553112.tar.bz2 fetchmail-ab245dddc6a34d6dd2965bf1f74071590c553112.zip |
Replace most strncpy() by strlcpy() calls.
-rw-r--r-- | kerberos.c | 6 | ||||
-rw-r--r-- | smtp.c | 3 | ||||
-rw-r--r-- | socket.c | 2 | ||||
-rw-r--r-- | transact.c | 6 |
4 files changed, 6 insertions, 11 deletions
@@ -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'; } @@ -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) @@ -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) @@ -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)); } } |