Commit 2386be28 authored by Ondřej Surý's avatar Ondřej Surý Committed by Mark Andrews
Browse files

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

(cherry picked from commit 175f0694)
parent fb68ed9a
Pipeline #7019 passed with stages
in 7 minutes and 52 seconds
......@@ -59,6 +59,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>
......@@ -437,12 +438,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[255] = '\0';
sizeof(host));
}
foundHost = true;
break;
......
......@@ -155,8 +155,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);
......
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