From 7c89c76e2d99180d4d3526944fb55ed28f36922e Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Thu, 8 Apr 2021 10:28:21 +0900 Subject: [PATCH] DLP: Use Curl_inet_pton() to get a network address conn->ip_addr points to a struct within the DNS cache, so this pointer is only valid as long as the DNS cache entry remains locked. Whereas conn->ip_addr_str is available while using the connection. Change-Id: I8cf239dda0b0d504427afe9809c0f0dcd2264f8d --- lib/sendf.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/sendf.c b/lib/sendf.c index 0fc3708..3611c73 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -34,6 +34,7 @@ #ifdef HAVE_TIZEN_DLP #include "extensions/curl_extensions.h" +#include "inet_pton.h" #endif #include "urldata.h" #include "sendf.h" @@ -308,10 +309,11 @@ CURLcode Curl_write(struct connectdata *conn, #ifdef HAVE_TIZEN_DLP u_int32_t destination_ipv4 = 0; - if(conn->ip_addr != NULL && conn->ip_addr->ai_family == AF_INET && - conn->ip_addr->ai_addr != NULL) { - destination_ipv4 = - ((struct sockaddr_in *) conn->ip_addr->ai_addr)->sin_addr.s_addr; + if(conn->ip_addr_str != NULL) { + struct in_addr in; + if(Curl_inet_pton(AF_INET, conn->ip_addr_str, &in) == 1) { + destination_ipv4 = in.s_addr; + } } curl_extensions_dlp_check_leak(conn->host.dispname, -- 2.7.4