http.c: cookie file tightening
commit4f5822076f41d13258f82bd2ff7bde2630a611a0
authorJunio C Hamano <gitster@pobox.com>
Tue, 9 Jul 2024 23:03:48 +0000 (9 16:03 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Jul 2024 04:28:38 +0000 (9 21:28 -0700)
tree10b86eed869cc241ca86927729a78510870c9e58
parentdbecc617f75eea6ee5d05823a38b91223ff22b11
http.c: cookie file tightening

The http.cookiefile configuration variable is used to call
curl_easy_setopt() to set CURLOPT_COOKIEFILE and if http.savecookies
is set, the same value is used for CURLOPT_COOKIEJAR.  The former is
used only to read cookies at startup, the latter is used to write
cookies at the end.

The manual pages https://curl.se/libcurl/c/CURLOPT_COOKIEFILE.html
and https://curl.se/libcurl/c/CURLOPT_COOKIEJAR.html talk about two
interesting special values.

 * "" (an empty string) given to CURLOPT_COOKIEFILE means not to
   read cookies from any file upon startup.

 * It is not specified what "" (an empty string) given to
   CURLOPT_COOKIEJAR does; presumably open a file whose name is an
   empty string and write cookies to it?  In any case, that is not
   what we want to see happen, ever.

 * "-" (a dash) given to CURLOPT_COOKIEFILE makes cURL read cookies
   from the standard input, and given to CURLOPT_COOKIEJAR makes
   cURL write cookies to the standard output.  Neither of which we
   want ever to happen.

So, let's make sure we avoid these nonsense cases.  Specifically,
when http.cookies is set to "-", ignore it with a warning, and when
it is set to "" and http.savecookies is set, ignore http.savecookies
with a warning.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
http.c