From 2e3e5db6680de463d6e8b43ec8bc5e131a99a700 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 22 Aug 2001 17:00:32 +0000 Subject: Update. 2001-08-22 Jakub Jelinek * sunrpc/xdr_rec.c (xdrrec_create): Fix buf sizes before allocating buf. Free resources on failure. * sunrpc/svc_unix.c (svcunix_create): Free resources on failure. (makefd_xprt): Likewise. * sunrpc/svc_udp.c (svcudp_bufcreate): Likewise. * sunrpc/svc_tcp.c (svctcp_create, makefd_xprt): Likewise. * sunrpc/auth_unix.c (authunix_create): Likewise. 2001-08-21 Jakub Jelinek * string/strnlen.c: Remove. * sysdeps/generic/strnlen.c: New. * sysdeps/i386/i486/bits/string.h (strnlen): Remove. --- sunrpc/xdr_rec.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'sunrpc/xdr_rec.c') diff --git a/sunrpc/xdr_rec.c b/sunrpc/xdr_rec.c index 65ffa3799e..941afa35de 100644 --- a/sunrpc/xdr_rec.c +++ b/sunrpc/xdr_rec.c @@ -146,7 +146,11 @@ xdrrec_create (XDR *xdrs, u_int sendsize, { RECSTREAM *rstrm = (RECSTREAM *) mem_alloc (sizeof (RECSTREAM)); caddr_t tmp; - char *buf = mem_alloc (sendsize + recvsize + BYTES_PER_XDR_UNIT); + char *buf; + + sendsize = fix_buf_size (sendsize); + recvsize = fix_buf_size (recvsize); + buf = mem_alloc (sendsize + recvsize + BYTES_PER_XDR_UNIT); if (rstrm == NULL || buf == NULL) { @@ -156,6 +160,8 @@ xdrrec_create (XDR *xdrs, u_int sendsize, else #endif (void) fputs (_("xdrrec_create: out of memory\n"), stderr); + mem_free (rstrm, sizeof (RECSTREAM)); + mem_free (buf, sendsize + recvsize + BYTES_PER_XDR_UNIT); /* * This is bad. Should rework xdrrec_create to * return a handle, and in this case return NULL @@ -165,8 +171,8 @@ xdrrec_create (XDR *xdrs, u_int sendsize, /* * adjust sizes and allocate buffer quad byte aligned */ - rstrm->sendsize = sendsize = fix_buf_size (sendsize); - rstrm->recvsize = recvsize = fix_buf_size (recvsize); + rstrm->sendsize = sendsize; + rstrm->recvsize = recvsize; rstrm->the_buffer = buf; tmp = rstrm->the_buffer; if ((size_t)tmp % BYTES_PER_XDR_UNIT) -- cgit v1.2.1