X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/7f18595b3ef9a348719969889097adb4f45d44f0..3b5607fc31371190470074371793cb8500b5139e:/apt-pkg/contrib/netrc.cc diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index c5f9630c4..feaed67c8 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -15,13 +15,13 @@ #include #include -#include #include #include #include #include #include +#include #include #include "netrc.h" @@ -39,8 +39,8 @@ enum { }; /* make sure we have room for at least this size: */ -#define LOGINSIZE 64 -#define PASSWORDSIZE 64 +#define LOGINSIZE 256 +#define PASSWORDSIZE 256 #define NETRC DOT_CHAR "netrc" /* returns -1 on failure, 0 if the host is found, 1 is the host isn't found */ @@ -49,14 +49,10 @@ static int parsenetrc_string (char *host, std::string &login, std::string &passw FILE *file; int retcode = 1; int specific_login = (login.empty() == false); - char *home = NULL; bool netrc_alloc = false; - int state_our_login = false; /* With specific_login, - found *our* login name */ - if (!netrcfile) { - home = getenv ("HOME"); /* portable environment reader */ + char const * home = getenv ("HOME"); /* portable environment reader */ if (!home) { struct passwd *pw; @@ -85,6 +81,8 @@ static int parsenetrc_string (char *host, std::string &login, std::string &passw int state = NOTHING; char state_login = 0; /* Found a login keyword */ char state_password = 0; /* Found a password keyword */ + int state_our_login = false; /* With specific_login, + found *our* login name */ while (!done && getline(&netrcbuffer, &netrcbuffer_size, file) != -1) { tok = strtok_r (netrcbuffer, " \t\n", &tok_buf); @@ -199,7 +197,7 @@ void maybe_add_auth (URI &Uri, string NetRCFile) // if host did not work, try Host+Path next, this will trigger // a lookup uri.startswith(host) in the netrc file parser (because // of the "/" - char *hostpath = strdup(string(Uri.Host+Uri.Path).c_str()); + char *hostpath = strdup((Uri.Host + Uri.Path).c_str()); if (hostpath && parsenetrc_string(hostpath, login, password, netrcfile) == 0) { if (_config->FindB("Debug::Acquire::netrc", false) == true)