cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH] typecheck: allow NULL to unset CURLOPT_ERRORBUFFER

From: Dave Reisner <d_at_falconindy.com>
Date: Mon, 10 Oct 2011 21:24:40 -0400

There might be situations where a user would want to unset this option.
Avoid forcing him/her to cast the NULL argument to (char *) in order to
get past the compile time typecheck.

---
I ran into this problem [1] on an FTP transfer which tripped the speedcheck on
shutting down the connection. Since, at that point, the error buffer tied to
the easy handle was stack allocated and well out of scope, it resulted in a
lovely stack smashing alert, killing the process. The easy solution is to unset
the error buffer after I, the developer, declare the transfer complete, but it
seems wrong to have to cast the NULL value to a type char* in order to do this.
[1] https://bugs.archlinux.org/task/26327
 include/curl/typecheck-gcc.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/include/curl/typecheck-gcc.h b/include/curl/typecheck-gcc.h
index 4e00ca9..5c584b0 100644
--- a/include/curl/typecheck-gcc.h
+++ b/include/curl/typecheck-gcc.h
@@ -392,7 +392,8 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
 /* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
 /* XXX: also check size of an char[] array? */
 #define _curl_is_error_buffer(expr)                                           \
-  (__builtin_types_compatible_p(__typeof__(expr), char *) ||                  \
+  (_curl_is_NULL(expr) ||                                                     \
+   __builtin_types_compatible_p(__typeof__(expr), char *) ||                  \
    __builtin_types_compatible_p(__typeof__(expr), char[]))
 
 /* evaluates to true if expr is of type (const) void* or (const) FILE* */
-- 
1.7.7
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-10-11