From 0371c0c5eb17c81e8dd44c4aa31b58318e9b7b72 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 19 Sep 2004 21:00:12 +0000 Subject: fix segfault from memory allocation: handle->entries is actualy struct ipt_get_entries plus the size --- libiptc/libiptc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libiptc/libiptc.c') diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c index f6a0233a..f017e498 100644 --- a/libiptc/libiptc.c +++ b/libiptc/libiptc.c @@ -1,4 +1,4 @@ -/* Library which manipulates firewall rules. Version $Revision: 1.48 $ */ +/* Library which manipulates firewall rules. Version $Revision: 1.49 $ */ /* Architecture of firewall rules is as follows: * @@ -750,11 +750,12 @@ alloc_handle(const char *tablename, unsigned int size, unsigned int num_rules) INIT_LIST_HEAD(&h->chains); strcpy(h->info.name, tablename); - h->entries = malloc(size); + h->entries = malloc(sizeof(STRUCT_GET_ENTRIES) + size); if (!h->entries) goto out_free_handle; strcpy(h->entries->name, tablename); + h->entries->size = size; return h; -- cgit v1.2.3