Cumulative patch from commit 20ff2642e192437245422c9654463bcebf65b277
20ff264 WPS: Clear WPS data on init failure
f19e370 WPS: Do not advertise WPA/WPA2-Enterprise Auth Type Flags
1b5df9e nl80211: Do not indicate scan started event on scan_for_auth
bb23826 HS 2.0R2: Clean up debug log during exit path
48408fc HS 2.0R2: Do not mandate OCSP response for EST operations
8f60293 HS 2.0R2: Do not use OSU cert validation for EST
40bdcea HS 2.0R2: Configure OSU client trust root more consistently
4d65ded HS 2.0R2: Clean up debug from libcurl
Change-Id: I44aa20ac92abf03ea7b47f1ecad72dc07a0870d9
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/src/utils/http_curl.c b/src/utils/http_curl.c
index 668c1a6..07d9af0 100644
--- a/src/utils/http_curl.c
+++ b/src/utils/http_curl.c
@@ -1,6 +1,6 @@
/*
* HTTP wrapper for libcurl
- * Copyright (c) 2012-2013, Qualcomm Atheros, Inc.
+ * Copyright (c) 2012-2014, Qualcomm Atheros, Inc.
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
@@ -82,15 +82,28 @@
static void debug_dump(struct http_ctx *ctx, const char *title,
const char *buf, size_t len)
{
- char *txt = os_malloc(len + 1);
+ char *txt;
+ size_t i;
+
+ for (i = 0; i < len; i++) {
+ if (buf[i] < 32 && buf[i] != '\t' && buf[i] != '\n' &&
+ buf[i] != '\r') {
+ wpa_hexdump_ascii(MSG_MSGDUMP, title, buf, len);
+ return;
+ }
+ }
+
+ txt = os_malloc(len + 1);
if (txt == NULL)
return;
os_memcpy(txt, buf, len);
txt[len] = '\0';
while (len > 0) {
len--;
- if (txt[len] == '\r' || txt[len] == '\n')
- txt[len] = '\0';
+ if (txt[len] == '\n' || txt[len] == '\r')
+ txt[len] = '\0';
+ else
+ break;
}
wpa_printf(MSG_MSGDUMP, "%s[%s]", title, txt);
os_free(txt);
@@ -134,21 +147,11 @@
}
-static size_t curl_cb_header(void *ptr, size_t size, size_t nmemb,
- void *userdata)
-{
- struct http_ctx *ctx = userdata;
- debug_dump(ctx, "curl header", ptr, size * nmemb);
- return size * nmemb;
-}
-
-
static size_t curl_cb_write(void *ptr, size_t size, size_t nmemb,
void *userdata)
{
struct http_ctx *ctx = userdata;
char *n;
- debug_dump(ctx, "curl write", ptr, size * nmemb);
n = os_realloc(ctx->curl_buf, ctx->curl_buf_len + size * nmemb + 1);
if (n == NULL)
return 0;
@@ -1275,8 +1278,6 @@
curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);
curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, curl_cb_debug);
curl_easy_setopt(curl, CURLOPT_DEBUGDATA, ctx);
- curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, curl_cb_header);
- curl_easy_setopt(curl, CURLOPT_HEADERDATA, ctx);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_cb_write);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, ctx);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
@@ -1527,8 +1528,6 @@
}
curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, curl_cb_debug);
curl_easy_setopt(curl, CURLOPT_DEBUGDATA, ctx);
- curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, curl_cb_header);
- curl_easy_setopt(curl, CURLOPT_HEADERDATA, ctx);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, f);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);