]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use strlcpy in place where strncpy(s, ...) + s[sizeof(s)-1] = \0; was used
authorOndřej Surý <ondrej@sury.org>
Mon, 19 Nov 2018 06:10:43 +0000 (07:10 +0100)
committerOndřej Surý <ondrej@sury.org>
Mon, 19 Nov 2018 06:58:48 +0000 (07:58 +0100)
contrib/dlz/drivers/dlz_filesystem_driver.c
lib/dns/rdata/in_1/wks_11.c

index 9fa03806807cd53f47a718b8f5d5981e2d877d67..97186e44335b66589e3ed2c4f9e3a2c2cd510055 100644 (file)
@@ -60,6 +60,7 @@
 #include <isc/platform.h>
 #include <isc/print.h>
 #include <isc/result.h>
+#include <isc/string.h>
 #include <isc/util.h>
 
 #include <named/globals.h>
@@ -438,12 +439,12 @@ process_dir(isc_dir_t *dir, void *passback, config_data_t *cd,
                                         */
                                        if (strcmp((char *) &dir->entry.name[6],
                                                   "-") == 0)
-                                               strcpy(host, "*");
-                                       else {
-                                               strncpy(host,
+                                       {
+                                               strlcpy(host, "*", sizeof(host));
+                                       } else {
+                                               strlcpy(host,
                                                   (char *) &dir->entry.name[6],
-                                                  sizeof(host) - 1);
-                                               host[NAME_MAX-1] = '\0';
+                                                  sizeof(host));
                                        }
                                        foundHost = true;
                                        break;
index 00d09dbda1f928f2fecb10fc95960dffc887b3f5..be5755412c875b69f6448f9f08af7901dc9f2019 100644 (file)
@@ -156,8 +156,7 @@ fromtext_in_wks(ARGS_FROMTEXT) {
                 * Lowercase the service string as some getservbyname() are
                 * case sensitive and the database is usually in lowercase.
                 */
-               strncpy(service, DNS_AS_STR(token), sizeof(service));
-               service[sizeof(service)-1] = '\0';
+               strlcpy(service, DNS_AS_STR(token), sizeof(service));
                for (i = strlen(service) - 1; i >= 0; i--)
                        if (isupper(service[i]&0xff))
                                service[i] = tolower(service[i]&0xff);