]> git.ipfire.org Git - thirdparty/curl.git/commit
cookies: Improve errorhandling for reading cookiefile
authorDaniel Gustafsson <daniel@yesql.se>
Wed, 20 Apr 2022 12:17:29 +0000 (14:17 +0200)
committerDaniel Gustafsson <daniel@yesql.se>
Wed, 20 Apr 2022 12:17:29 +0000 (14:17 +0200)
commita6cdfd24eed5778da4d080e7c139a00ba9282ca0
treeb69d79b49ad8c369f84197beea938b34888d0ae7
parentd794d4bce24f8850a4f09e6d6f4ebc38b73a65d0
cookies: Improve errorhandling for reading cookiefile

The existing programming had some issues with errorhandling for reading
the cookie file. If the file failed to open, we would silently ignore it
and continue as if there was no file (or stdin) passed. In this case, we
would also call fclose() on the NULL FILE pointer, which is undefined
behavior. Fix by ensuring that the FILE pointer is set before calling
fclose on it, and issue a warning in case the file cannot be opened.
Erroring out on nonexisting file would break backwards compatibility of
very old behavior so we can't really go there.

Closes: #8699
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Reviewed-by: Jay Satiro <raysatiro@yahoo.com>
lib/cookie.c