From e0df7ed3f1a6bc3d9164dde7f25b8ed582388a9b Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 3 Oct 2008 23:11:47 +0200 Subject: [PATCH] src/utils_ignorelist.c: Fix an off-by-one errror when adding regular expressions. Resolves: #20 --- src/utils_ignorelist.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils_ignorelist.c b/src/utils_ignorelist.c index 1d9467fe..689b4a42 100644 --- a/src/utils_ignorelist.c +++ b/src/utils_ignorelist.c @@ -306,11 +306,13 @@ 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); + strncpy (entry_copy, entry + 1, entry_copy_size); + entry_copy[entry_copy_size - 1] = 0; DEBUG("I'm about to add regex entry: %s", entry_copy); ret = ignorelist_append_regex(il, entry_copy); -- 2.30.2