summaryrefslogtreecommitdiffstats
path: root/lib/libc/rpc/auth_unix.c
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2007-03-25 18:49:13 +0000
committerotto <otto@openbsd.org>2007-03-25 18:49:13 +0000
commitc975e2177ad398ce25cf5f920e851cb621ef5cf0 (patch)
tree670f1689f91bf50b35a23de3de2cb2123850c8c1 /lib/libc/rpc/auth_unix.c
parentRemove LK_INTERLOCK from flags in a call to vget(); (diff)
downloadwireguard-openbsd-c975e2177ad398ce25cf5f920e851cb621ef5cf0.tar.xz
wireguard-openbsd-c975e2177ad398ce25cf5f920e851cb621ef5cf0.zip
eliminate call to abort(), which is very bad in libs. I forgat how
this diff came into my tree, apologies for not naming the contributor. ok tedu@ deraadt@
Diffstat (limited to 'lib/libc/rpc/auth_unix.c')
-rw-r--r--lib/libc/rpc/auth_unix.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c
index 8d8080d5b77..432b6a1ca7f 100644
--- a/lib/libc/rpc/auth_unix.c
+++ b/lib/libc/rpc/auth_unix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth_unix.c,v 1.20 2006/11/10 17:29:31 grunk Exp $ */
+/* $OpenBSD: auth_unix.c,v 1.21 2007/03/25 18:49:13 otto Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -136,7 +136,7 @@ authunix_create(char *machname, int uid, int gid, int len, int *aup_gids)
*/
xdrmem_create(&xdrs, mymem, MAX_AUTH_BYTES, XDR_ENCODE);
if (!xdr_authunix_parms(&xdrs, &aup))
- abort(); /* XXX abort illegal in library */
+ goto authfail;
au->au_origcred.oa_length = len = XDR_GETPOS(&xdrs);
au->au_origcred.oa_flavor = AUTH_UNIX;
#ifdef KERNEL
@@ -144,10 +144,7 @@ authunix_create(char *machname, int uid, int gid, int len, int *aup_gids)
#else
if ((au->au_origcred.oa_base = mem_alloc((u_int) len)) == NULL) {
(void)fprintf(stderr, "authunix_create: out of memory\n");
- XDR_DESTROY(&xdrs);
- free(au);
- free(auth);
- return (NULL);
+ goto authfail;
}
#endif
memcpy(au->au_origcred.oa_base, mymem, (u_int)len);
@@ -158,6 +155,12 @@ authunix_create(char *machname, int uid, int gid, int len, int *aup_gids)
auth->ah_cred = au->au_origcred;
marshal_new_auth(auth);
return (auth);
+
+authfail:
+ XDR_DESTROY(&xdrs);
+ free(au);
+ free(auth);
+ return (NULL);
}