Loading lib/netrc.c +15 −14 Original line number Diff line number Diff line Loading @@ -62,8 +62,6 @@ int Curl_parsenetrc(const char *host, FILE *file; int retcode=1; int specific_login = (**loginp != 0); char *home = NULL; bool home_alloc = FALSE; bool netrc_alloc = FALSE; enum host_lookup_state state=NOTHING; Loading @@ -74,7 +72,8 @@ int Curl_parsenetrc(const char *host, #define NETRC DOT_CHAR "netrc" if(!netrcfile) { home = curl_getenv("HOME"); /* portable environment reader */ bool home_alloc = FALSE; char *home = curl_getenv("HOME"); /* portable environment reader */ if(home) { home_alloc = TRUE; #if defined(HAVE_GETPWUID) && defined(HAVE_GETEUID) Loading @@ -92,15 +91,17 @@ int Curl_parsenetrc(const char *host, return -1; netrcfile = curl_maprintf("%s%s%s", home, DIR_CHAR, NETRC); if(!netrcfile) { if(home_alloc) free(home); Curl_safefree(home); if(!netrcfile) { return -1; } netrc_alloc = TRUE; } file = fopen(netrcfile, "r"); if(netrc_alloc) Curl_safefree(netrcfile); if(file) { char *tok; char *tok_buf; Loading Loading @@ -146,8 +147,10 @@ int Curl_parsenetrc(const char *host, else { free(*loginp); *loginp = strdup(tok); if(!*loginp) return -1; /* allocation failed */ if(!*loginp) { retcode = -1; /* allocation failed */ goto out; } } state_login=0; } Loading @@ -155,8 +158,10 @@ int Curl_parsenetrc(const char *host, if(state_our_login || !specific_login) { free(*passwordp); *passwordp = strdup(tok); if(!*passwordp) return -1; /* allocation failed */ if(!*passwordp) { retcode = -1; /* allocation failed */ goto out; } } state_password=0; } Loading @@ -176,13 +181,9 @@ int Curl_parsenetrc(const char *host, } /* while(tok) */ } /* while fgets() */ out: fclose(file); } if(home_alloc) free(home); if(netrc_alloc) free(netrcfile); return retcode; } Loading
lib/netrc.c +15 −14 Original line number Diff line number Diff line Loading @@ -62,8 +62,6 @@ int Curl_parsenetrc(const char *host, FILE *file; int retcode=1; int specific_login = (**loginp != 0); char *home = NULL; bool home_alloc = FALSE; bool netrc_alloc = FALSE; enum host_lookup_state state=NOTHING; Loading @@ -74,7 +72,8 @@ int Curl_parsenetrc(const char *host, #define NETRC DOT_CHAR "netrc" if(!netrcfile) { home = curl_getenv("HOME"); /* portable environment reader */ bool home_alloc = FALSE; char *home = curl_getenv("HOME"); /* portable environment reader */ if(home) { home_alloc = TRUE; #if defined(HAVE_GETPWUID) && defined(HAVE_GETEUID) Loading @@ -92,15 +91,17 @@ int Curl_parsenetrc(const char *host, return -1; netrcfile = curl_maprintf("%s%s%s", home, DIR_CHAR, NETRC); if(!netrcfile) { if(home_alloc) free(home); Curl_safefree(home); if(!netrcfile) { return -1; } netrc_alloc = TRUE; } file = fopen(netrcfile, "r"); if(netrc_alloc) Curl_safefree(netrcfile); if(file) { char *tok; char *tok_buf; Loading Loading @@ -146,8 +147,10 @@ int Curl_parsenetrc(const char *host, else { free(*loginp); *loginp = strdup(tok); if(!*loginp) return -1; /* allocation failed */ if(!*loginp) { retcode = -1; /* allocation failed */ goto out; } } state_login=0; } Loading @@ -155,8 +158,10 @@ int Curl_parsenetrc(const char *host, if(state_our_login || !specific_login) { free(*passwordp); *passwordp = strdup(tok); if(!*passwordp) return -1; /* allocation failed */ if(!*passwordp) { retcode = -1; /* allocation failed */ goto out; } } state_password=0; } Loading @@ -176,13 +181,9 @@ int Curl_parsenetrc(const char *host, } /* while(tok) */ } /* while fgets() */ out: fclose(file); } if(home_alloc) free(home); if(netrc_alloc) free(netrcfile); return retcode; }