From 2fbe7ab6ce2c06975bc7e4cec19867bc90e67d61 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sun, 12 Aug 2012 03:38:45 +0200 Subject: [PATCH] Only accept pointers to valid types for getinfo(). --- indra/llmessage/aicurl.cpp | 2 +- indra/llmessage/aicurlprivate.h | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/indra/llmessage/aicurl.cpp b/indra/llmessage/aicurl.cpp index edbcfec83..daba6f923 100644 --- a/indra/llmessage/aicurl.cpp +++ b/indra/llmessage/aicurl.cpp @@ -657,7 +657,7 @@ void CurlEasyHandle::setErrorBuffer(void) } } -CURLcode CurlEasyHandle::getinfo(CURLINFO info, void* data) +CURLcode CurlEasyHandle::getinfo_priv(CURLINFO info, void* data) { setErrorBuffer(); return check_easy_code(curl_easy_getinfo(mEasyHandle, info, data)); diff --git a/indra/llmessage/aicurlprivate.h b/indra/llmessage/aicurlprivate.h index a39120faa..309992973 100644 --- a/indra/llmessage/aicurlprivate.h +++ b/indra/llmessage/aicurlprivate.h @@ -111,11 +111,21 @@ class CurlEasyHandle : public boost::noncopyable, protected AICurlEasyHandleEven char* unescape(char* url, int inlength , int* outlength); // Extract information from a curl handle. - CURLcode getinfo(CURLINFO info, void* data); -#if _WIN64 || __x86_64__ || __ppc64__ + private: + CURLcode getinfo_priv(CURLINFO info, void* data); + public: + // The rest are inlines to provide some type-safety. + CURLcode getinfo(CURLINFO info, char** data) { return getinfo_priv(info, data); } + CURLcode getinfo(CURLINFO info, curl_slist** data) { return getinfo_priv(info, data); } + CURLcode getinfo(CURLINFO info, double* data) { return getinfo_priv(info, data); } + CURLcode getinfo(CURLINFO info, long* data) { return getinfo_priv(info, data); } +#ifdef __LP64__ // sizeof(long) > sizeof(int) ? // Overload for integer types that are too small (libcurl demands a long). - CURLcode getinfo(CURLINFO info, S32* data) { long ldata; CURLcode res = getinfo(info, &ldata); *data = static_cast(ldata); return res; } - CURLcode getinfo(CURLINFO info, U32* data) { long ldata; CURLcode res = getinfo(info, &ldata); *data = static_cast(ldata); return res; } + CURLcode getinfo(CURLINFO info, S32* data) { long ldata; CURLcode res = getinfo_priv(info, &ldata); *data = static_cast(ldata); return res; } + CURLcode getinfo(CURLINFO info, U32* data) { long ldata; CURLcode res = getinfo_priv(info, &ldata); *data = static_cast(ldata); return res; } +#else + CURLcode getinfo(CURLINFO info, S32* data) { return getinfo_priv(info, static_cast(data)); } + CURLcode getinfo(CURLINFO info, U32* data) { return getinfo_priv(info, static_cast(data)); } #endif // Perform a file transfer (blocking).