From: Thomas Jarosch Date: Mon, 18 Oct 2010 09:31:34 +0000 (+0200) Subject: Fix HTTP request output parsing: Don't read past the curl buffer end X-Git-Tag: v1.1~38 X-Git-Url: http://developer.intra2net.com/git/?p=bpdyndnsd;a=commitdiff_plain;h=0955e6a29f5deeb4fb9871e19449b200ae160c36 Fix HTTP request output parsing: Don't read past the curl buffer end --- diff --git a/src/httphelper.cpp b/src/httphelper.cpp index 997599a..eb35fd9 100644 --- a/src/httphelper.cpp +++ b/src/httphelper.cpp @@ -293,9 +293,8 @@ CURLcode HTTPHelper::set_curl_auth(const string& username, const string& passwor * @param outBuffer Pointer to output stream. * @return The size received. */ -size_t HTTPHelper::http_receive( const char *inBuffer, size_t size, size_t nmemb, string *outBuffer ) +size_t HTTPHelper::http_receive( void *inBuffer, size_t size, size_t nmemb, string *outBuffer ) { - outBuffer->append(inBuffer); + outBuffer->append(static_cast(inBuffer), size*nmemb); return (size*nmemb); -} - +} //lint !e818 diff --git a/src/httphelper.hpp b/src/httphelper.hpp index abc984a..8f29e9f 100644 --- a/src/httphelper.hpp +++ b/src/httphelper.hpp @@ -58,7 +58,7 @@ public: void re_initialize(); // libcurl is a C library, so we have to make the callback member function static :-( - static size_t http_receive(const char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer); + static size_t http_receive(void *inBuffer, size_t size, size_t nmemb, std::string *outBuffer); }; #endif diff --git a/src/ip_addr_helper.cpp b/src/ip_addr_helper.cpp index 3293ee1..16359dd 100644 --- a/src/ip_addr_helper.cpp +++ b/src/ip_addr_helper.cpp @@ -613,11 +613,11 @@ CURL * IPAddrHelper::init_curl(string& curl_writedata_buff,char* curl_err_buff) * @param outBuffer Pointer to output stream. * @return The size received. */ -size_t IPAddrHelper::http_receive( const char *inBuffer, size_t size, size_t nmemb, string *outBuffer ) +size_t IPAddrHelper::http_receive( void *inBuffer, size_t size, size_t nmemb, string *outBuffer ) { - outBuffer->append(inBuffer); + outBuffer->append(static_cast(inBuffer), size*nmemb); return (size*nmemb); -} +} //lint !e818 /** diff --git a/src/ip_addr_helper.hpp b/src/ip_addr_helper.hpp index 8615148..c150f39 100644 --- a/src/ip_addr_helper.hpp +++ b/src/ip_addr_helper.hpp @@ -66,7 +66,7 @@ public: std::string get_local_wan_nic_ip() const; // libcurl is a C library, so we have to make the callback member function static :-( - static size_t http_receive(const char *inBuffer, size_t size, size_t nmemb, std::string *outBuffer); + static size_t http_receive(void *inBuffer, size_t size, size_t nmemb, std::string *outBuffer); time_t get_last_webcheck() const; };