NETRCcode ret = NETRC_FILE_MISSING; /* if it cannot open the file */
FILE *file = curlx_fopen(filename, FOPEN_READTEXT);
+ curlx_dyn_reset(filebuf);
if(file) {
curlx_struct_stat stat;
if((curlx_fstat(fileno(file), &stat) == -1) || !S_ISDIR(stat.st_mode)) {
{
struct dynbuf *filebuf = &store->filebuf;
- if(!store->loaded) {
- NETRCcode ret = file2memory(netrcfile, filebuf);
+ if(!store->loaded || strcmp(netrcfile, store->filename)) {
+ NETRCcode ret;
+ store->loaded = FALSE;
+ ret = file2memory(netrcfile, filebuf);
if(ret) {
CURL_TRC_M(data, "[NETRC] could not load '%s'", netrcfile);
return ret;
}
+ curlx_free(store->filename);
+ store->filename = curlx_strdup(netrcfile);
+ if(!store->filename) {
+ curlx_dyn_reset(&store->filebuf);
+ return NETRC_OUT_OF_MEMORY;
+ }
store->loaded = TRUE;
}
struct Curl_creds **pcreds)
{
NETRCcode retcode = NETRC_OK;
- char *filealloc = NULL;
CURL_TRC_M(data, "[NETRC] scanning '%s' for host '%s' user '%s'",
netrcfile, hostname, user);
if(!netrcfile) {
char *home = NULL;
char *homea = NULL;
+ char *filealloc = NULL;
#if defined(HAVE_GETPWUID_R) && defined(HAVE_GETEUID)
char pwbuf[1024];
#endif
{
curlx_dyn_init(&store->filebuf, MAX_NETRC_FILE);
store->loaded = FALSE;
+ store->filename = NULL;
}
void Curl_netrc_cleanup(struct store_netrc *store)
{
curlx_dyn_free(&store->filebuf);
+ curlx_safefree(store->filename);
store->loaded = FALSE;
}