X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Futils_ignorelist.c;h=0ad252bb79336bb6d98e11613a5c03b698a6de58;hp=1d9467fe210d89e6ce0f9c6537e3be9e389d6e8e;hb=633c3966f770e4d46651a2fe219a18d8a9907a9f;hpb=9451dd777d3adb37e51f34a48f772e66d54b1f85 diff --git a/src/utils_ignorelist.c b/src/utils_ignorelist.c index 1d9467fe..0ad252bb 100644 --- a/src/utils_ignorelist.c +++ b/src/utils_ignorelist.c @@ -1,7 +1,7 @@ /** * collectd - src/utils_ignorelist.c * Copyright (C) 2006 Lubos Stanek - * Copyright (C) 2008 Florian Forster + * Copyright (C) 2008 Florian Forster * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- @@ -20,7 +20,7 @@ * * Authors: * Lubos Stanek - * Florian Forster + * Florian Forster **/ /** * ignorelist handles plugin's list of configured collectable @@ -306,11 +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); - strncpy (entry_copy, entry + 1, entry_len - 2); + 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);