Fix lengths of interface names
Use helper function similar to copy correctly limited names into
buffers.
diff --git a/src/rfc2131.c b/src/rfc2131.c
index 5809126..64e8167 100644
--- a/src/rfc2131.c
+++ b/src/rfc2131.c
@@ -949,7 +949,7 @@
mess->siaddr = a_record_from_hosts(boot->tftp_sname, now);
if (boot->file)
- strncpy((char *)mess->file, boot->file, sizeof(mess->file)-1);
+ safe_strncpy((char *)mess->file, boot->file, sizeof(mess->file));
}
option_put(mess, end, OPTION_MESSAGE_TYPE, 1,
@@ -2360,7 +2360,7 @@
in_list(req_options, OPTION_SNAME))
option_put_string(mess, end, OPTION_SNAME, boot->sname, 1);
else
- strncpy((char *)mess->sname, boot->sname, sizeof(mess->sname)-1);
+ safe_strncpy((char *)mess->sname, boot->sname, sizeof(mess->sname));
}
if (boot->file)
@@ -2370,7 +2370,7 @@
in_list(req_options, OPTION_FILENAME))
option_put_string(mess, end, OPTION_FILENAME, boot->file, 1);
else
- strncpy((char *)mess->file, boot->file, sizeof(mess->file)-1);
+ safe_strncpy((char *)mess->file, boot->file, sizeof(mess->file));
}
if (boot->next_server.s_addr)
@@ -2387,14 +2387,14 @@
if ((!req_options || !in_list(req_options, OPTION_FILENAME)) &&
(opt = option_find2(OPTION_FILENAME)) && !(opt->flags & DHOPT_FORCE))
{
- strncpy((char *)mess->file, (char *)opt->val, sizeof(mess->file)-1);
+ safe_strncpy((char *)mess->file, (char *)opt->val, sizeof(mess->file));
done_file = 1;
}
if ((!req_options || !in_list(req_options, OPTION_SNAME)) &&
(opt = option_find2(OPTION_SNAME)) && !(opt->flags & DHOPT_FORCE))
{
- strncpy((char *)mess->sname, (char *)opt->val, sizeof(mess->sname)-1);
+ safe_strncpy((char *)mess->sname, (char *)opt->val, sizeof(mess->sname));
done_server = 1;
}