Commit 175f0694 authored by Ondřej Surý's avatar Ondřej Surý
Browse files

Use strlcpy in place where strncpy(s, ...) + s[sizeof(s)-1] = \0; was used

parent aa4ac49b
Pipeline #6922 passed with stages
in 8 minutes and 15 seconds
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include <isc/platform.h> #include <isc/platform.h>
#include <isc/print.h> #include <isc/print.h>
#include <isc/result.h> #include <isc/result.h>
#include <isc/string.h>
#include <isc/util.h> #include <isc/util.h>
#include <named/globals.h> #include <named/globals.h>
...@@ -438,12 +439,12 @@ process_dir(isc_dir_t *dir, void *passback, config_data_t *cd, ...@@ -438,12 +439,12 @@ process_dir(isc_dir_t *dir, void *passback, config_data_t *cd,
*/ */
if (strcmp((char *) &dir->entry.name[6], if (strcmp((char *) &dir->entry.name[6],
"-") == 0) "-") == 0)
strcpy(host, "*"); {
else { strlcpy(host, "*", sizeof(host));
strncpy(host, } else {
strlcpy(host,
(char *) &dir->entry.name[6], (char *) &dir->entry.name[6],
sizeof(host) - 1); sizeof(host));
host[NAME_MAX-1] = '\0';
} }
foundHost = true; foundHost = true;
break; break;
......
...@@ -156,8 +156,7 @@ fromtext_in_wks(ARGS_FROMTEXT) { ...@@ -156,8 +156,7 @@ fromtext_in_wks(ARGS_FROMTEXT) {
* Lowercase the service string as some getservbyname() are * Lowercase the service string as some getservbyname() are
* case sensitive and the database is usually in lowercase. * case sensitive and the database is usually in lowercase.
*/ */
strncpy(service, DNS_AS_STR(token), sizeof(service)); strlcpy(service, DNS_AS_STR(token), sizeof(service));
service[sizeof(service)-1] = '\0';
for (i = strlen(service) - 1; i >= 0; i--) for (i = strlen(service) - 1; i >= 0; i--)
if (isupper(service[i]&0xff)) if (isupper(service[i]&0xff))
service[i] = tolower(service[i]&0xff); service[i] = tolower(service[i]&0xff);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment