Plug memory leaks, from Roman Divacky.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24824 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2009-02-27 03:25:22 +00:00
parent 8c21864ae3
commit f4680be3ce

View File

@@ -167,6 +167,7 @@ login (char *host)
char tmp[80]; char tmp[80];
char defaultpass[128]; char defaultpass[128];
char *userstr, *pass, *acctstr; char *userstr, *pass, *acctstr;
char *ruserstr, *rpass, *racctstr;
int n, aflag = 0; int n, aflag = 0;
char *myname = NULL; char *myname = NULL;
@@ -175,7 +176,7 @@ login (char *host)
if (pw != NULL) if (pw != NULL)
myname = pw->pw_name; myname = pw->pw_name;
userstr = pass = acctstr = 0; ruserstr = rpass = racctstr = NULL;
if(sec_login(host)) if(sec_login(host))
printf("\n*** Using plaintext user and password ***\n\n"); printf("\n*** Using plaintext user and password ***\n\n");
@@ -183,10 +184,14 @@ login (char *host)
printf("Authentication successful.\n\n"); printf("Authentication successful.\n\n");
} }
if (ruserpass (host, &userstr, &pass, &acctstr) < 0) { if (ruserpass (host, &ruserstr, &rpass, &racctstr) < 0) {
code = -1; code = -1;
return (0); return (0);
} }
userstr = ruserstr;
pass = rpass;
acctstr = racctstr;
while (userstr == NULL) { while (userstr == NULL) {
if (myname) if (myname)
printf ("Name (%s:%s): ", host, myname); printf ("Name (%s:%s): ", host, myname);
@@ -201,6 +206,9 @@ login (char *host)
userstr = tmp; userstr = tmp;
} }
strlcpy(username, userstr, sizeof(username)); strlcpy(username, userstr, sizeof(username));
if (ruserstr)
free(ruserstr);
n = command("USER %s", userstr); n = command("USER %s", userstr);
if (n == COMPLETE) if (n == COMPLETE)
n = command("PASS dummy"); /* DK: Compatibility with gssftp daemon */ n = command("PASS dummy"); /* DK: Compatibility with gssftp daemon */
@@ -227,19 +235,25 @@ login (char *host)
} }
} }
n = command ("PASS %s", pass); n = command ("PASS %s", pass);
if (rpass)
free(rpass);
} }
if (n == CONTINUE) { if (n == CONTINUE) {
aflag++; aflag++;
UI_UTIL_read_pw_string (tmp, sizeof(tmp), "Account:", 0);
acctstr = tmp; acctstr = tmp;
UI_UTIL_read_pw_string (acctstr, 128, "Account:", 0);
n = command ("ACCT %s", acctstr); n = command ("ACCT %s", acctstr);
} }
if (n != COMPLETE) { if (n != COMPLETE) {
if (racctstr)
free(racctstr);
warnx ("Login failed."); warnx ("Login failed.");
return (0); return (0);
} }
if (!aflag && acctstr != NULL) if (!aflag && acctstr != NULL)
command ("ACCT %s", acctstr); command ("ACCT %s", acctstr);
if (racctstr)
free(racctstr);
if (proxy) if (proxy)
return (1); return (1);
for (n = 0; n < macnum; ++n) { for (n = 0; n < macnum; ++n) {