From 3846463e0784dc1315ed07fcc9a604e12012b051 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 29 May 2000 18:04:55 +0000 Subject: Update. 2000-05-29 Ulrich Drepper * inet/Makefile (CFLAGS-rcmd.c, CFLAGS-rexec.c, CFLAGS-ruserpass.c): Removed. * inet/rcmd.c: Remove __P. Remove unused variables. (iruserfopen): Make first parameter const. (ruserok_sa): Return result of ruserok2_sa. (__checkhost_sa): Correctly iterate through results of getaddrinfo. * inet/rexec.c: Remove unused variables. Other small cleanups. * inet/ruserpass.c: Remove __P. Remove unused variables. (ruserpass): Check results of memory allocation. * include/netdb.h: Add prototype for ruserpass. --- inet/ruserpass.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'inet/ruserpass.c') diff --git a/inet/ruserpass.c b/inet/ruserpass.c index 70bfdd4..18d8e14 100644 --- a/inet/ruserpass.c +++ b/inet/ruserpass.c @@ -37,6 +37,7 @@ static char sccsid[] = "@(#)ruserpass.c 8.3 (Berkeley) 4/2/94"; #include #include #include +#include #include #include #include @@ -45,7 +46,7 @@ static char sccsid[] = "@(#)ruserpass.c 8.3 (Berkeley) 4/2/94"; /* #include "ftp_var.h" */ -static int token __P((void)); +static int token (void); static FILE *cfile; #define DEFAULT 1 @@ -93,11 +94,11 @@ static const struct toktab { int ruserpass(host, aname, apass) - char *host, **aname, **apass; + const char *host, **aname, **apass; { char *hdir, *buf, *tmp; char myname[1024], *mydomain; - int t, i, c, usedefault = 0; + int t, usedefault = 0; struct stat stb; hdir = __secure_getenv("HOME"); @@ -157,14 +158,21 @@ next: while ((t = token()) && t != MACHINE && t != DEFAULT) switch(t) { case LOGIN: - if (token()) + if (token()) { if (*aname == 0) { - *aname = malloc((unsigned) strlen(tokval) + 1); - (void) strcpy(*aname, tokval); + char *newp; + newp = malloc((unsigned) strlen(tokval) + 1); + if (newp == NULL) + { + warnx(_("out of memory")); + goto bad; + } + *aname = strcpy(newp, tokval); } else { if (strcmp(*aname, tokval)) goto next; } + } break; case PASSWD: if (strcmp(*aname, "anonymous") && @@ -175,8 +183,14 @@ next: goto bad; } if (token() && *apass == 0) { - *apass = malloc((unsigned) strlen(tokval) + 1); - (void) strcpy(*apass, tokval); + char *newp; + newp = malloc((unsigned) strlen(tokval) + 1); + if (newp == NULL) + { + warnx(_("out of memory")); + goto bad; + } + *apass = strcpy(newp, tokval); } break; case ACCOUNT: -- cgit v1.1