First sorry for completely forgetting about this patch series.

Am 25.08.21 um 23:02 schrieb selva.n...@gmail.com:
From: Selva Nair <selva.n...@gmail.com>

Selecting the remote host via the management iterface

Typo in interface

+
+static bool
+management_callback_remote_entry_get(void *arg, unsigned int index, char 
**remote)
+{
+    assert(arg);
+    assert(remote);
+
+    struct context *c = (struct context *) arg;
+    struct connection_list *l = c->options.connection_list;
+    bool ret = true;
+
+    if (index < l->len)
+    {
+        struct connection_entry *ce = l->array[index];
+        const char *proto = proto2ascii(ce->proto, ce->af, false);
+
+        /* space for output including 2 commas and a nul */
+        int len = strlen(ce->remote) + strlen(ce->remote_port) + strlen(proto) 
+ 2 + 1;
+        char *out = malloc(len);
+        check_malloc_return(out);

Not sure that we need to exit the program here instead of of return false but the error is so seldom that it does not really matter. Using gc_arena would have been also a bit nicer but not too problematic.

+
+        openvpn_snprintf(out, len, "%s,%s,%s", ce->remote, ce->remote_port, 
proto);
+        *remote = out;
+    }
+    else
+    {
+        ret = false;
+        msg(M_WARN, "Out of bounds index in management query for remote entry: 
index = %u", index);
+    }
+
+    return ret;

I feel we could eliminate ret variable here and just do return true and return false from the true branches of the if.

There are minor things that could be improved but the current state is still acceptable.

Acked-By: Arne Schwabe <a...@rfc2549.org>



_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to