Skip to contentSkip to conversation

Fix socks_proxy_port pointing to invalid data

PATCH In review Thomas Veerman 4 participants 4 messages Jul 7, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix socks_proxy_port pointing to invalid data

When setting the SOCKS proxy through the management interface, the socks_proxy_port pointer would be set to a value that's no longer valid by the time it's used by do_preresolve_host.

---
 src/openvpn/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/init.c +1 -1
index a54307ad..80a8f5fa 100644
@@ -150,7 +150,7 @@ management_callback_proxy_cmd(void *arg, const char **p)
         else if (streq(p[1], "SOCKS"))
         {
             ce->socks_proxy_server = string_alloc(p[2], gc);
-            ce->socks_proxy_port = p[3];
+            ce->socks_proxy_port = string_alloc(p[3], gc);
             ret = true;
         }
     }
Signature · 1 line
2.11.0 (Apple Git-81)
#1 lore raw

Am 07.07.17 um 21:59 schrieb Thomas Veerman via Openvpn-devel:

Quoted 15 lines

When setting the SOCKS proxy through the management interface, the socks_proxy_port pointer would be set to a value that's no longer valid by the time it's used by do_preresolve_host.

---
 src/openvpn/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/init.c +0 -0
index a54307ad..80a8f5fa 100644

src/openvpn/init.c management_callback_proxy_cmd(void *arg, const char **p) · line 156

Quoted 8 lines
src/openvpn/init.c +1 -1
@@ -150,7 +150,7 @@ management_callback_proxy_cmd(void *arg, const char **p)
         else if (streq(p[1], "SOCKS"))
         {
             ce->socks_proxy_server = string_alloc(p[2], gc);
-            ce->socks_proxy_port = p[3];
+            ce->socks_proxy_port = string_alloc(p[3], gc);
             ret = true;
         }
     }

ACK. Probably my fault, when I changed that from int to string.

Arne

#2 lore raw
In reply to Thomas Veerman

Thomas Veerman via Openvpn-devel <[email protected]> on Fri, 2017/07/07 21:59:

src/openvpn/init.c management_callback_proxy_cmd(void *arg, const char **p) · line 156

Quoted 8 lines
         else if (streq(p[1], "SOCKS"))
         {
             ce->socks_proxy_server = string_alloc(p[2], gc);
src/openvpn/init.c +1 -1
-            ce->socks_proxy_port = p[3];
+            ce->socks_proxy_port = string_alloc(p[3], gc);
             ret = true;
         }
     }

If we allocate memory here, is it freed later?

A quick look at options.h shows this is (const char *).

Signature · 3 lines
main(a){char*c=/*    Schoene Gruesse                         */"B?IJj;MEH"
"CX:;",b;for(a/*    Best regards             my address:    */=0;b=c[a++];)
putchar(b-1/(/*    Chris            cc -ox -xc - && ./x    */b/42*2-3)*42);}
#3 lore raw
Quoted 11 lines · Christian Hesse

Thomas Veerman via Openvpn-devel <[email protected]> on Fri, 2017/07/07 21:59:

src/openvpn/init.c management_callback_proxy_cmd(void *arg, const char **p) · line 156

Quoted 8 lines
         else if (streq(p[1], "SOCKS"))
         {
             ce->socks_proxy_server = string_alloc(p[2], gc);
src/openvpn/init.c +1 -1
-            ce->socks_proxy_port = p[3];
+            ce->socks_proxy_port = string_alloc(p[3], gc);
             ret = true;
         }
     }
Quoted 3 lines

If we allocate memory here, is it freed later?

A quick look at options.h shows this is (const char *).

It is allocated with a gc (garbage collector), so when there is is a gc_free() on the gc, all allocations connected to that gc gets freed all at once.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Technologies, Inc