]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix PASS_BY_VALUE issue in options_postprocess_mutate_le()
authorGianmarco De Gregori <gianmarco@mandelbit.com>
Fri, 24 Jan 2025 13:00:00 +0000 (14:00 +0100)
committerGert Doering <gert@greenie.muc.de>
Fri, 24 Jan 2025 13:58:47 +0000 (14:58 +0100)
Fix issue reported by Coverity:
CID 1641424: Performance inefficiencies (PASS_BY_VALUE)
    Passing parameter ce of type "struct connection_entry"
    (size 208 bytes) by value, which exceeds the low
    threshold of 128 bytes.

Commit 8466c2ca unintentionally introduced a performance
penalty due to passing struct connection_entry 'ce'
by value to options_postprocess_mutate_le().
fix this by passing 'ce' by address.

Change-Id: I0542df021ae0ba9c982335fed7bbd10ed326dd0f
Signed-off-by: Gianmarco De Gregori <gianmarco@mandelbit.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20250124130000.20067-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30566.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/options.c

index c938999cd63f05bdbb3e87d05f1a4d123d87500b..bd5c056c7fa4d1737a3924e0015167dbb3d3abb0 100644 (file)
@@ -3323,12 +3323,12 @@ options_postprocess_mutate_ce(struct options *o, struct connection_entry *ce)
 }
 
 static void
-options_postprocess_mutate_le(struct connection_entry ce, struct local_entry *le)
+options_postprocess_mutate_le(struct connection_entry *ce, struct local_entry *le)
 {
     /* use the global port if none is specified */
     if (!le->port)
     {
-        le->port = ce.local_port;
+        le->port = ce->local_port;
     }
 }
 
@@ -3777,7 +3777,7 @@ options_postprocess_mutate(struct options *o, struct env_set *es)
     {
         for (i = 0; i < o->ce.local_list->len; i++)
         {
-            options_postprocess_mutate_le(o->ce, o->ce.local_list->array[i]);
+            options_postprocess_mutate_le(&o->ce, o->ce.local_list->array[i]);
         }
     }
     else