diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | include/netdb.h | 3 | ||||
-rw-r--r-- | inet/rcmd.c | 51 | ||||
-rw-r--r-- | inet/rexec.c | 13 | ||||
-rw-r--r-- | inet/ruserpass.c | 30 |
5 files changed, 66 insertions, 44 deletions
@@ -1,3 +1,16 @@ +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. + 2000-05-29 Jakub Jelinek <jakub@redhat.com> * inet/rcmd.c (rresvport_af): Use correct port number. diff --git a/include/netdb.h b/include/netdb.h index f7f570e..26b8cf5 100644 --- a/include/netdb.h +++ b/include/netdb.h @@ -77,4 +77,7 @@ extern int __getnetgrent_r (char **__restrict __hostp, char **__restrict __userp, char **__restrict __domainp, char *__restrict __buffer, size_t __buflen); + +extern int ruserpass (const char *host, const char **aname, + const char **apass); #endif /* !_NETDB_H */ diff --git a/inet/rcmd.c b/inet/rcmd.c index 12081e8..758f6c9 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -81,9 +81,9 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; #include <stdlib.h> -int __ivaliduser __P ((FILE *, u_int32_t, const char *, const char *)); -static int __validuser2_sa __P ((FILE *, struct sockaddr *, size_t, - const char *, const char *, const char *)); +int __ivaliduser (FILE *, u_int32_t, const char *, const char *); +static int __validuser2_sa (FILE *, struct sockaddr *, size_t, + const char *, const char *, const char *); static int ruserok2_sa (struct sockaddr *ra, size_t ralen, int superuser, const char *ruser, const char *luser, const char *rhost); @@ -106,8 +106,6 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) sa_family_t af; { char paddr[INET6_ADDRSTRLEN]; - size_t hstbuflen; - char *tmphstbuf; struct addrinfo hints, *res, *ai; struct sockaddr_storage from; struct pollfd pfd[2]; @@ -314,7 +312,7 @@ rresvport_af(alport, family) struct sockaddr_storage ss; int s; size_t len; - uint16_t *sport, i; + uint16_t *sport; switch(family){ case AF_INET: @@ -401,7 +399,7 @@ ruserok(rhost, superuser, ruser, luser) /* Extremely paranoid file open function. */ static FILE * -iruserfopen (char *file, uid_t okuser) +iruserfopen (const char *file, uid_t okuser) { struct stat st; char *cp = NULL; @@ -519,7 +517,7 @@ static int ruserok_sa(ra, ralen, superuser, ruser, luser) int superuser; const char *ruser, *luser; { - ruserok2_sa(ra, ralen, superuser, ruser, luser, "-"); + return ruserok2_sa(ra, ralen, superuser, ruser, luser, "-"); } /* This is the exported version. */ @@ -590,19 +588,13 @@ __ivaliduser(hostf, raddr, luser, ruser) /* Returns 1 on positive match, 0 on no match, -1 on negative match. */ static int internal_function -__checkhost_sa (ra, ralen, lhost, rhost) - struct sockaddr *ra; - size_t ralen; - char *lhost; - const char *rhost; +__checkhost_sa (struct sockaddr *ra, size_t ralen, char *lhost, + const char *rhost) { struct addrinfo hints, *res0, *res; - int herr; - int save_errno; char raddr[INET6_ADDRSTRLEN]; int match; int negate=1; /* Multiply return with this to get -1 instead of 1 */ - char *user; /* Check nis netgroup. */ if (strncmp ("+@", lhost, 2) == 0) @@ -632,29 +624,29 @@ __checkhost_sa (ra, ralen, lhost, rhost) hints.ai_family = ra->sa_family; if (getaddrinfo(lhost, NULL, &hints, &res0) == 0){ /* Spin through ip addresses. */ - for (res=res0; res; res->ai_next){ - if (res->ai_family == ra->sa_family && - !memcmp(res->ai_addr, ra, res->ai_addrlen)){ - match = 1; - break; - } - } - freeaddrinfo(res0); + for (res = res0; res; res = res->ai_next) + { + if (res->ai_family == ra->sa_family + && !memcmp(res->ai_addr, ra, res->ai_addrlen)) + { + match = 1; + break; + } + } + freeaddrinfo (res0); } - return (negate * match); + return negate * match; } /* Returns 1 on positive match, 0 on no match, -1 on negative match. */ static int internal_function -__icheckuser (luser, ruser) - const char *luser, *ruser; +__icheckuser (const char *luser, const char *ruser) { /* luser is user entry from .rhosts/hosts.equiv file ruser is user id on remote host */ - char *user; /* [-+]@netgroup */ if (strncmp ("+@", luser, 2) == 0) @@ -679,8 +671,7 @@ __icheckuser (luser, ruser) * Returns 1 for blank lines (or only comment lines) and 0 otherwise */ static int -__isempty(p) - char *p; +__isempty (char *p) { while (*p && isspace (*p)) { ++p; diff --git a/inet/rexec.c b/inet/rexec.c index 8a977c6..decee94 100644 --- a/inet/rexec.c +++ b/inet/rexec.c @@ -40,6 +40,7 @@ static char sccsid[] = "@(#)rexec.c 8.1 (Berkeley) 6/4/93"; #include <stdio.h> #include <netdb.h> #include <errno.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -58,11 +59,10 @@ rexec_af(ahost, rport, name, pass, cmd, fd2p, af) struct addrinfo hints, *res0; const char *orig_name = name; const char *orig_pass = pass; - u_short port; + u_short port = 0; int s, timo = 1, s3; char c; - int herr; - int gai, ok; + int gai; char servbuff[NI_MAXSERV]; snprintf(servbuff, sizeof(servbuff), "%d", rport); @@ -72,7 +72,8 @@ rexec_af(ahost, rport, name, pass, cmd, fd2p, af) hints.ai_family = af; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_CANONNAME; - if (gai = getaddrinfo(*ahost, servbuff, &hints, &res0)){ + gai = getaddrinfo(*ahost, servbuff, &hints, &res0); + if (gai){ /* XXX: set errno? */ return -1; } @@ -148,9 +149,9 @@ retry: /* We don't need the memory allocated for the name and the password in ruserpass anymore. */ if (name != orig_name) - free (name); + free ((char *) name); if (pass != orig_pass) - free (pass); + free ((char *) pass); if (__read(s, &c, 1) != 1) { perror(*ahost); 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 <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: |