Those were introduced when unifying the string handling in commit
5f9ec13b in
cases where the exact length of the string to be copied is passed to sstrncpy
instead of the size of the destination buffer.
In case of the iptables plugin this prevented the table or chain name to match
correctly as the user configuration was truncated. In case of the ignorelist a
given regex was truncated.
Signed-off-by: Sebastian Harl <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
table = fields[0];
chain = fields[1];
- table_len = strlen (table);
- if ((unsigned int)table_len >= sizeof(temp.table))
+ table_len = strlen (table) + 1;
+ if ((unsigned int)table_len > sizeof(temp.table))
{
ERROR ("Table `%s' too long.", table);
free (value_copy);
}
sstrncpy (temp.table, table, table_len);
- chain_len = strlen (chain);
- if ((unsigned int)chain_len >= sizeof(temp.chain))
+ chain_len = strlen (chain) + 1;
+ if ((unsigned int)chain_len > sizeof(temp.chain))
{
ERROR ("Chain `%s' too long.", chain);
free (value_copy);
/* We need to copy `entry' since it's const */
entry_copy = smalloc (entry_len);
memset (entry_copy, '\0', entry_len);
- sstrncpy (entry_copy, entry + 1, entry_len - 2);
+ /* sstrncpy() overwrites the trailing '/' */
+ sstrncpy (entry_copy, entry + 1, entry_len - 1);
DEBUG("I'm about to add regex entry: %s", entry_copy);
ret = ignorelist_append_regex(il, entry_copy);