From 31622c7dc75c79faad42f6501f6a38fe8c9cd34e Mon Sep 17 00:00:00 2001 From: laforge 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(-) diff --git a/libiptc/libiptc.c b/libiptc/libiptc.c index f6a0233..f017e49 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