curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: The application does not have to keep the string around after setting this option

From: Patrick Monnerat via curl-library <curl-library_at_lists.haxx.se>
Date: Thu, 20 Apr 2023 13:14:24 +0200

On 4/20/23 12:31, Timothe Litt via curl-library wrote:
>
> On 20-Apr-23 05:24, Frank Gevaerts via curl-library wrote:
>> On Wed, Apr 19, 2023 at 06:47:42PM +0200, Andreas Falkenhahn via curl-library wrote:
>>> Many manpages of curl options that take a string say: "The application does not have to keep the string around after setting this option". Does this imply that curl options which do NOT contain this phrase must ensure the string pointer passed to the option remains valid after calling curl_easy_setopt()?
>> In principle, yes. Oversights happen so some manpages might not have
>> that paragraph while they should though.
>
> If there are any cases where the string is not copied and must be
> retained, the documentation should say so explicitly.
>
The documentation DOES say so.

The only exception is CURLOPT_POSTFIELDS, because the postfield string
might be associated to the CURLOPT_POSTFIELDSIZE option rather than
being null-terminated. There is however an alternate option
CURLOPT_COPYPOSTFIELDS.

 From the CURLOPT_POSTFIELDS man page:

---
The  data pointed to is NOT copied by the library: as a consequence, it
        must be preserved by  the  calling  application  until the  
associated
        transfer  finishes.  This behavior can be changed (so libcurl 
does copy
        the data) by setting the CURLOPT_COPYPOSTFIELDS(3) option.
---
The only other option that passes a character pointer and is not subject 
to copying is CURLOPT_ERRORBUFFER, because it specifies an output 
buffer, not an input string.(directions seen from libcurl standview, of 
course).
Blob data copying is controlled by a flag in the curl_blob itself.
The rest is pretty orthogonal.
Patrick
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2023-04-20