2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

[master] null terminate strings for coverity

This commit is contained in:
Evan Hunt
2014-06-16 15:30:11 -07:00
parent e3468c9052
commit 56510cd031
6 changed files with 39 additions and 4 deletions

View File

@@ -331,15 +331,20 @@ insert_into_typenames(int type, const char *typename, const char *attr) {
exit(1);
}
/* XXXMUKS: This is redundant due to the INSIST above. */
if (strlen(typename) > sizeof(ttn->typename) - 1) {
fprintf(stderr, "Error: type name %s is too long\n",
typename);
exit(1);
}
strncpy(ttn->typename, typename, sizeof(ttn->typename));
ttn->type = type;
ttn->typename[sizeof(ttn->typename) - 1] = '\0';
strncpy(ttn->macroname, ttn->typename, sizeof(ttn->macroname));
ttn->macroname[sizeof(ttn->macroname) - 1] = '\0';
ttn->type = type;
c = strlen(ttn->macroname);
while (c > 0) {
if (ttn->macroname[c - 1] == '-')
@@ -365,7 +370,10 @@ insert_into_typenames(int type, const char *typename, const char *attr) {
attr, typename);
exit(1);
}
strncpy(ttn->attr, attr, sizeof(ttn->attr));
ttn->attr[sizeof(ttn->attr) - 1] = '\0';
ttn->sorted = 0;
if (maxtype < type)
maxtype = type;
@@ -394,11 +402,17 @@ add(int rdclass, const char *classname, int type, const char *typename,
newtt->next = NULL;
newtt->rdclass = rdclass;
newtt->type = type;
strncpy(newtt->classname, classname, sizeof(newtt->classname));
newtt->classname[sizeof(newtt->classname) - 1] = '\0';
strncpy(newtt->typename, typename, sizeof(newtt->typename));
newtt->typename[sizeof(newtt->typename) - 1] = '\0';
if (strncmp(dirname, "./", 2) == 0)
dirname += 2;
strncpy(newtt->dirname, dirname, sizeof(newtt->dirname));
newtt->dirname[sizeof(newtt->dirname) - 1] = '\0';
tt = types;
oldtt = NULL;