]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/netrc.cc
Merge remote-tracking branch 'upstream/debian/sid' into feature/source-deb822
[apt.git] / apt-pkg / contrib / netrc.cc
index c5f9630c4b7c2ca7e4e1fd7a184f77bb191ab923..de95aa4ab68e8273837f11de0f3ac2bfc530e0b7 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <apt-pkg/configuration.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/error.h>
 #include <apt-pkg/fileutl.h>
 
 #include <iostream>
@@ -39,8 +40,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 +50,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 +82,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);