about summary refs log tree commit diff
path: root/inet/ruserpass.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-05-29 18:04:55 +0000
committerUlrich Drepper <drepper@redhat.com>2000-05-29 18:04:55 +0000
commit3846463e0784dc1315ed07fcc9a604e12012b051 (patch)
treeacff1b6e670be6957c41eeb56be9862f8495e949 /inet/ruserpass.c
parent41b5aaf9c93b45455c51666b6c273d2ae56008a3 (diff)
downloadglibc-3846463e0784dc1315ed07fcc9a604e12012b051.tar.gz
glibc-3846463e0784dc1315ed07fcc9a604e12012b051.tar.xz
glibc-3846463e0784dc1315ed07fcc9a604e12012b051.zip
Update.
2000-05-29  Ulrich Drepper  <drepper@redhat.com>

	* 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.
Diffstat (limited to 'inet/ruserpass.c')
-rw-r--r--inet/ruserpass.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 70bfdd4c8d..18d8e1462a 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 <ctype.h>
 #include <err.h>
 #include <errno.h>
+#include <netdb.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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: