netrc: free temporary strings if memory allocation fails #3122
- Change the inout parameters after all needed memory has been allocated. Do not change them if something goes wrong. - Free the allocated temporary strings if strdup() fails
This fixes a bug found by the torture tests: https://curl.haxx.se/dev/log.cgi?id=20181007082759-19055#prob1
There appears to be a bug with this change where netrc lookup now fails to select the correct entry, instead defaulting to the first user entry every time. This was working in v7.61.1 and earlier.
Example netrc file:
The following examples running under Solaris 11 pick up the wrong netrc user entry:
curl --verbose --netrc --user fdxfer: ftp://ftp.gam.com
curl --verbose --netrc --user pilling: ftp://ftp.gam.com