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: Empty file name in CURLOPT_COOKIEFILE optimization

From: Dan Fandrich via curl-library <curl-library_at_lists.haxx.se>
Date: Wed, 13 Dec 2023 13:53:22 -0800

On Wed, Dec 13, 2023 at 09:49:07PM +0000, Dmitry Karpov via curl-library wrote:
> I propose to add a simple check for the cookie file name length and call fopen() only if it is greater than zero like:

Sounds reasonable.

> if(data) {
> FILE *fp = NULL;
> - if(file) {
> + if(file && strlen(file) > 0) {
> if(!strcmp(file, "-"))

This forces a traversal of the entire string, which isn't necessary. This would
be much faster:

    if(file && *file) {

Are you able to turn this into a PR?

Dan
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2023-12-13