Message ID | 20250618140016.2766-1-gert@greenie.muc.de |
---|---|
State | New |
Headers | show |
Series | [Openvpn-devel,v1] Multi-socket: local_list clean-up | expand |
Stared-at-code, looks good. Tested on the server instance with lots of --local lines (+ some msg() calls to see l->len and l_capacity), and it does what it promises. Thanks :-) Your patch has been applied to the master branch. commit 9bb02bc34f5ecc85364fa7ab64e52b6c5c918055 Author: Gianmarco De Gregori Date: Wed Jun 18 16:00:09 2025 +0200 Multi-socket: local_list clean-up Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20250618140016.2766-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg31927.html Signed-off-by: Gert Doering <gert@greenie.muc.de> -- kind regards, Gert Doering
diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 6ea01d4..70337b1 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -2212,12 +2212,20 @@ struct local_list *l = alloc_local_list_if_undef(ce, gc); struct local_entry *e; - if (l->len >= CONNECTION_LIST_SIZE) + if (l->len >= l->capacity) { - msg(msglevel, "Maximum number of 'local' options (%d) exceeded", - CONNECTION_LIST_SIZE); + const int new_cap = l->capacity + 1; + const size_t elem_size = sizeof(*l->array); - return NULL; + struct local_entry **new_array = gc_realloc(l->array, new_cap * elem_size, gc); + if (!new_array) + { + msg(msglevel, "Unable to process more local options: out of memory. Number of entries = %d", l->len); + return NULL; + } + + l->array = new_array; + l->capacity = new_cap; } ALLOC_OBJ_CLEAR_GC(e, struct local_entry, gc); diff --git a/src/openvpn/options.h b/src/openvpn/options.h index b28ad58..46ec32b 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -188,8 +188,9 @@ struct local_list { + int capacity; int len; - struct local_entry *array[CONNECTION_LIST_SIZE]; + struct local_entry **array; }; struct connection_list