diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-06-05 17:19:01 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2009-06-05 17:19:01 +0000 |
commit | 56fdb47bf3dde0a7a410f7d932703da9d12d696c (patch) | |
tree | 3d7299afada427098cda3dc9c88d068026839742 | |
parent | e33fb5e0ae7d29fcd5a1ea7a5ab160311593342e (diff) |
improve yp_bind(3) error reporting after clnttcp_create(3) failure:
map ECONNREFUSED -> YPERR_YPBIND, ENOMEM -> YPERR_RESRC, else YPERR_YPERR
while here, malloc(3) failure should raise YPERR_RESRC, not YPERR_YPERR
ok millert@
-rw-r--r-- | lib/libc/yp/yp_bind.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/libc/yp/yp_bind.c b/lib/libc/yp/yp_bind.c index fa8fa63531d..80197adb674 100644 --- a/lib/libc/yp/yp_bind.c +++ b/lib/libc/yp/yp_bind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: yp_bind.c,v 1.16 2007/09/17 07:07:23 moritz Exp $ */ +/* $OpenBSD: yp_bind.c,v 1.17 2009/06/05 17:19:00 schwarze Exp $ */ /* * Copyright (c) 1992, 1993, 1996 Theo de Raadt <deraadt@theos.com> * All rights reserved. @@ -98,7 +98,7 @@ _yp_dobind(const char *dom, struct dom_binding **ypdb) break; if (ysd == NULL) { if ((ysd = malloc(sizeof *ysd)) == NULL) - return YPERR_YPERR; + return YPERR_RESRC; (void)memset(ysd, 0, sizeof *ysd); ysd->dom_socket = -1; ysd->dom_vers = 0; @@ -164,7 +164,14 @@ trynet: clnt_pcreateerror("clnttcp_create"); if (new) free(ysd); - return YPERR_YPBIND; + switch (rpc_createerr.cf_error.re_errno) { + case ECONNREFUSED: + return YPERR_YPBIND; + case ENOMEM: + return YPERR_RESRC; + default: + return YPERR_YPERR; + } } if (ntohs(clnt_sin.sin_port) >= IPPORT_RESERVED || ntohs(clnt_sin.sin_port) == 20) { |