cURL / Mailing Lists / curl-library / Single Mail


Re: curlopt_seekfunction

From: Colin Ngam <>
Date: Sun, 2 Oct 2016 18:07:14 +0000


Is userp ever initialized? As is, it is going to be garbage ..



From: curl-library <> on behalf of Biju N <>
Reply-To: libcurl development <>
Date: Sunday, October 2, 2016 at 9:12 AM
To: libcurl development <>
Subject: Re: curlopt_seekfunction

Thanks Dan and Colin, A curl handler (d_curl) is used. Since I the original code is restricted, I had to type it myself to be make is more meaningful to ask the questions. Sorry about the typos.

        void* userp;

        res = curl_easy_setopt(d_curl, CURLOPT_SEEKDATA, userp);

        if (res != CURLE_OK)

             throw CurlError(res);

        res = curl_easy_setopt(d_curl, CURLOPT_SEEKFUNCTION, seek_callback);

        if (res != CURLE_OK)

             throw CurlError(res);

int seek_callback(void *userp, curl_off_t offset, int origin){

    FILE* in = static_cast<FILE *>(userp);

    long f_offset = (long) offset;

    int ret = fseek(in, f_offset, origin);

    return ret;


On Sat, Oct 1, 2016 at 1:35 AM, Dan Fandrich <<>> wrote:
On Fri, Sep 30, 2016 at 11:39:26PM +0000, Colin Ngam wrote:
> Hi,
> Why are you using *userp as a curl handle?
> CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter);

Indeed. And even if it is a curl handle (you didn't show that part of your
code), then it makes no sense to use it as a FILE* handle.

        res = curl_easy_setopt(d_curl, CURLOPT_SEEKDATA, *userp);
>>> Dan
List admin:<>

The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through anti virus and spam software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt.

List admin:
Received on 2016-10-02