summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/netrc.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-10-13 18:56:23 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-10-13 18:56:23 +0200
commit7f18595b3ef9a348719969889097adb4f45d44f0 (patch)
treef8b44e5a4c43518bca350ddde44a6a32a7b41713 /apt-pkg/contrib/netrc.cc
parentb8c50bd0415bd4ea16a8f09356d882f267976d40 (diff)
remove 256 char line limit by using getline() (POSIX.1-2008)
Diffstat (limited to 'apt-pkg/contrib/netrc.cc')
-rw-r--r--apt-pkg/contrib/netrc.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc
index 950d21dad..c5f9630c4 100644
--- a/apt-pkg/contrib/netrc.cc
+++ b/apt-pkg/contrib/netrc.cc
@@ -79,13 +79,14 @@ static int parsenetrc_string (char *host, std::string &login, std::string &passw
char *tok;
char *tok_buf;
bool done = false;
- char netrcbuffer[256];
+ char *netrcbuffer = NULL;
+ size_t netrcbuffer_size = 0;
int state = NOTHING;
char state_login = 0; /* Found a login keyword */
char state_password = 0; /* Found a password keyword */
- while (!done && fgets(netrcbuffer, sizeof (netrcbuffer), file)) {
+ while (!done && getline(&netrcbuffer, &netrcbuffer_size, file) != -1) {
tok = strtok_r (netrcbuffer, " \t\n", &tok_buf);
while (!done && tok) {
if(login.empty() == false && password.empty() == false) {
@@ -142,8 +143,9 @@ static int parsenetrc_string (char *host, std::string &login, std::string &passw
tok = strtok_r (NULL, " \t\n", &tok_buf);
} /* while(tok) */
- } /* while fgets() */
+ } /* while getline() */
+ free(netrcbuffer);
fclose(file);
}