X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_ignorelist.c;h=de42d0fa399035e0f2e3930866d2be670557fc72;hb=2794e703be245165757b0bec50a6ba09ae5417f0;hp=db679dad83f9053e628c916032e23d8438b293a9;hpb=ee9507500f738d21858f76128501772d212c069c;p=collectd.git diff --git a/src/utils_ignorelist.c b/src/utils_ignorelist.c index db679dad..de42d0fa 100644 --- a/src/utils_ignorelist.c +++ b/src/utils_ignorelist.c @@ -306,12 +306,12 @@ int ignorelist_add (ignorelist_t *il, const char *entry) if ((entry_len > 2) && (entry[0] == '/') && entry[entry_len - 1] == '/') { char *entry_copy; + size_t entry_copy_size; /* We need to copy `entry' since it's const */ - entry_copy = smalloc (entry_len); - memset (entry_copy, '\0', entry_len); - /* sstrncpy() overwrites the trailing '/' */ - sstrncpy (entry_copy, entry + 1, entry_len - 1); + entry_copy_size = entry_len - 1; + entry_copy = smalloc (entry_copy_size); + sstrncpy (entry_copy, entry + 1, entry_copy_size); DEBUG("I'm about to add regex entry: %s", entry_copy); ret = ignorelist_append_regex(il, entry_copy);