- memmove -> memcpy
	- check that we don't get a bogus h->h_length
This commit is contained in:
christos 1998-11-15 17:25:39 +00:00
parent ae3564f2ff
commit ee3762617d
3 changed files with 20 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnt_generic.c,v 1.11 1998/02/13 05:52:15 lukem Exp $ */
/* $NetBSD: clnt_generic.c,v 1.12 1998/11/15 17:25:39 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -35,7 +35,7 @@
static char *sccsid = "@(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";
static char *sccsid = "@(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC";
#else
__RCSID("$NetBSD: clnt_generic.c,v 1.11 1998/02/13 05:52:15 lukem Exp $");
__RCSID("$NetBSD: clnt_generic.c,v 1.12 1998/11/15 17:25:39 christos Exp $");
#endif
#endif
@ -93,7 +93,9 @@ clnt_create(hostname, prog, vers, proto)
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_family = h->h_addrtype;
sin.sin_port = 0;
memmove((char*)&sin.sin_addr, h->h_addr, h->h_length);
if (h->h_length > sin.sin_len)
h->h_length = sin.sin_len;
memcpy(&sin.sin_addr.s_addr, h->h_addr, (size_t)h->h_length);
p = getprotobyname(proto);
if (p == NULL) {
rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;

View File

@ -1,4 +1,4 @@
/* $NetBSD: clnt_simple.c,v 1.13 1998/07/09 18:15:18 msaitoh Exp $ */
/* $NetBSD: clnt_simple.c,v 1.14 1998/11/15 17:25:39 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -35,7 +35,7 @@
static char *sccsid = "@(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC";
#else
__RCSID("$NetBSD: clnt_simple.c,v 1.13 1998/07/09 18:15:18 msaitoh Exp $");
__RCSID("$NetBSD: clnt_simple.c,v 1.14 1998/11/15 17:25:39 christos Exp $");
#endif
#endif
@ -110,8 +110,10 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
timeout.tv_usec = 0;
timeout.tv_sec = 5;
memset(&server_addr, 0, sizeof(server_addr));
memmove((char *)&server_addr.sin_addr, hp->h_addr,
hp->h_length);
if (hp->h_length > sizeof(struct sockaddr_in))
hp->h_length = sizeof(struct sockaddr_in);
memcpy(&server_addr.sin_addr.s_addr, hp->h_addr,
(size_t)hp->h_length);
server_addr.sin_len = sizeof(struct sockaddr_in);
server_addr.sin_family = AF_INET;
server_addr.sin_port = 0;
@ -125,7 +127,7 @@ callrpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
}
tottimeout.tv_sec = 25;
tottimeout.tv_usec = 0;
clnt_stat = clnt_call(crp->client, procnum, inproc, in,
clnt_stat = clnt_call(crp->client, (unsigned long)procnum, inproc, in,
outproc, out, tottimeout);
/*
* if call failed, empty cache

View File

@ -1,4 +1,4 @@
/* $NetBSD: getrpcport.c,v 1.12 1998/02/13 05:52:23 lukem Exp $ */
/* $NetBSD: getrpcport.c,v 1.13 1998/11/15 17:25:39 christos Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@ -35,7 +35,7 @@
static char *sccsid = "@(#)getrpcport.c 1.3 87/08/11 SMI";
static char *sccsid = "@(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC";
#else
__RCSID("$NetBSD: getrpcport.c,v 1.12 1998/02/13 05:52:23 lukem Exp $");
__RCSID("$NetBSD: getrpcport.c,v 1.13 1998/11/15 17:25:39 christos Exp $");
#endif
#endif
@ -73,6 +73,10 @@ getrpcport(host, prognum, versnum, proto)
addr.sin_len = sizeof(struct sockaddr_in);
addr.sin_family = AF_INET;
addr.sin_port = 0;
memmove((char *) &addr.sin_addr, hp->h_addr, hp->h_length);
return (pmap_getport(&addr, prognum, versnum, proto));
if (hp->h_length > addr.sin_len)
hp->h_length = addr.sin_len;
memcpy(&addr.sin_addr.s_addr, hp->h_addr, (size_t)hp->h_length);
/* Inconsistent interfaces need casts! :-( */
return (pmap_getport(&addr, (u_long)prognum, (u_long)versnum,
(u_int)proto));
}