Skip to contentSkip to conversation

proxy.c refactoring: remove always-NULL gc parameter

PATCH In review Gert Doering 2 participants 3 messages Jun 9, 2017 – Jun 12, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proxy.c refactoring: remove always-NULL gc parameter

get_proxy_authenticate() is called with a "gc" parameter which MUST be NULL, otherwise string_alloc() will allocate memory in the gc_arena while the caller expects the result to be durable and will do explicit free() when no longer needed. Remove gc parameter, call string_alloc() with "NULL" so this is clearly visible.

---
 src/openvpn/proxy.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
src/openvpn/proxy.c +2 -4
index 8ff09ba..05f362d 100644
@@ -309,7 +309,6 @@ static int
 get_proxy_authenticate(socket_descriptor_t sd,
                        int timeout,
                        char **data,
-                       struct gc_arena *gc,
                        volatile int *signal_received)
 {
     char buf[256];
@@ -332,14 +331,14 @@ get_proxy_authenticate(socket_descriptor_t sd,
             if (!strncmp(buf+20, "Basic ", 6))
             {
                 msg(D_PROXY, "PROXY AUTH BASIC: '%s'", buf);
-                *data = string_alloc(buf+26, gc);
+                *data = string_alloc(buf+26, NULL);
                 ret = HTTP_AUTH_BASIC;
             }
 #if PROXY_DIGEST_AUTH
             else if (!strncmp(buf+20, "Digest ", 7))
             {
                 msg(D_PROXY, "PROXY AUTH DIGEST: '%s'", buf);
-                *data = string_alloc(buf+27, gc);
+                *data = string_alloc(buf+27, NULL);
                 ret = HTTP_AUTH_DIGEST;
             }
 #endif
@@ -981,7 +980,6 @@ establish_http_proxy_passthru(struct http_proxy_info *p,
             const int method = get_proxy_authenticate(sd,
                                                       get_server_poll_remaining_time(server_poll_timeout),
                                                       &pa,
-                                                      NULL,
                                                       signal_received);
             if (method != HTTP_AUTH_NONE)
             {
Signature · 1 line
2.10.2
#1 lore raw

Hi,

Quoted 42 lines · Gert Doering

get_proxy_authenticate() is called with a "gc" parameter which MUST be NULL, otherwise string_alloc() will allocate memory in the gc_arena while the caller expects the result to be durable and will do explicit free() when no longer needed. Remove gc parameter, call string_alloc() with "NULL" so this is clearly visible.

---
 src/openvpn/proxy.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
src/openvpn/proxy.c +2 -3
index 8ff09ba..05f362d 100644
@@ -309,7 +309,6 @@ static int
 get_proxy_authenticate(socket_descriptor_t sd,
                        int timeout,
                        char **data,
-                       struct gc_arena *gc,
                        volatile int *signal_received)
 {
     char buf[256];
@@ -332,14 +331,14 @@ get_proxy_authenticate(socket_descriptor_t sd,
             if (!strncmp(buf+20, "Basic ", 6))
             {
                 msg(D_PROXY, "PROXY AUTH BASIC: '%s'", buf);
-                *data = string_alloc(buf+26, gc);
+                *data = string_alloc(buf+26, NULL);
                 ret = HTTP_AUTH_BASIC;
             }
 #if PROXY_DIGEST_AUTH
             else if (!strncmp(buf+20, "Digest ", 7))
             {
                 msg(D_PROXY, "PROXY AUTH DIGEST: '%s'", buf);
-                *data = string_alloc(buf+27, gc);
+                *data = string_alloc(buf+27, NULL);
                 ret = HTTP_AUTH_DIGEST;
             }
 #endif

src/openvpn/proxy.c establish_http_proxy_passthru(struct http_proxy_info *p, · line 985

Quoted 7 lines
src/openvpn/proxy.c +0 -1
@@ -981,7 +980,6 @@ establish_http_proxy_passthru(struct http_proxy_info *p,
             const int method = get_proxy_authenticate(sd,
                                                       get_server_poll_remaining_time(server_poll_timeout),
                                                       &pa,
-                                                      NULL,
                                                       signal_received);
             if (method != HTTP_AUTH_NONE)
             {

What a mess... This slightly reduces that, so ACK.

-Steffan

#2 lore raw
In reply to Gert Doering

Patch has been applied to the master branch.

commit 2dca268a643d4cfe375ef46950b57ef660073711

Author: Gert Doering
Date:   Fri Jun 9 22:50:29 2017 +0200
     proxy.c refactoring: remove always-NULL gc parameter

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Steffan Karger <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg14768.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering