summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-11-20 05:03:32 -0500
committerJakub Hrozek <jhrozek@redhat.com>2012-11-21 11:23:55 +0100
commit83cd233a74b264fe13523b5297447edf99288c3b (patch)
tree094f82512793dbbd1a6a45e82f2c2e4328411d8f
parentf9111f464376338317e30da637353e2c25869ce8 (diff)
downloadsssd-83cd233a74b264fe13523b5297447edf99288c3b.tar.gz
sssd-83cd233a74b264fe13523b5297447edf99288c3b.tar.xz
sssd-83cd233a74b264fe13523b5297447edf99288c3b.zip
MONITOR: Fix off-by-one error in add_string_to_list
We need to allocate num_services+2 - one extra space for the new service and one for NULL.
-rw-r--r--src/util/util.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/util/util.c b/src/util/util.c
index 18df0e847..ab980775a 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -656,7 +656,10 @@ errno_t add_string_to_list(TALLOC_CTX *mem_ctx, const char *string,
new_list = talloc_array(mem_ctx, char *, 2);
} else {
for (c = 0; old_list[c] != NULL; c++);
- new_list = talloc_realloc(mem_ctx, old_list, char *, c + 1);
+ /* Allocate one extra space for the new service and one for
+ * the terminating NULL
+ */
+ new_list = talloc_realloc(mem_ctx, old_list, char *, c + 2);
}
if (new_list == NULL) {