From owner-svn-src-stable-9@freebsd.org Wed Jan 13 05:32:25 2016 Return-Path: Delivered-To: svn-src-stable-9@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B63B1A80C9F; Wed, 13 Jan 2016 05:32:25 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 91B631159; Wed, 13 Jan 2016 05:32:25 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0D5WOqv025557; Wed, 13 Jan 2016 05:32:24 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0D5WOSN025556; Wed, 13 Jan 2016 05:32:24 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201601130532.u0D5WOSN025556@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Wed, 13 Jan 2016 05:32:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r293804 - stable/9/lib/libc/yp X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2016 05:32:25 -0000 Author: glebius Date: Wed Jan 13 05:32:24 2016 New Revision: 293804 URL: https://svnweb.freebsd.org/changeset/base/293804 Log: Merge r291073: If a NIS server has long entries on its database that is bigger than 1024 specified on YPMAXRECORD the ypmatch can get in an infinite retry loop when is requesting the information from the NIS server. The ypmatch(1) will return an error until the command receives an kill(1). To avoid this problem, we check the MAX_RETRIES that is by default set to 20 and avoid get in infinet loop at the client side. Modified: stable/9/lib/libc/yp/yplib.c Directory Properties: stable/9/ (props changed) stable/9/lib/ (props changed) stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/yp/yplib.c ============================================================================== --- stable/9/lib/libc/yp/yplib.c Wed Jan 13 04:11:04 2016 (r293803) +++ stable/9/lib/libc/yp/yplib.c Wed Jan 13 05:32:24 2016 (r293804) @@ -653,7 +653,7 @@ yp_match(char *indomain, char *inmap, co struct timeval tv; struct ypreq_key yprk; int r; - + int retries = 0; *outval = NULL; *outvallen = 0; @@ -691,6 +691,11 @@ yp_match(char *indomain, char *inmap, co #endif again: + if (retries > MAX_RETRIES) { + YPUNLOCK(); + return (YPERR_RPC); + } + if (_yp_dobind(indomain, &ysd) != 0) { YPUNLOCK(); return (YPERR_DOMAIN); @@ -707,6 +712,7 @@ again: if (r != RPC_SUCCESS) { clnt_perror(ysd->dom_client, "yp_match: clnt_call"); _yp_unbind(ysd); + retries++; goto again; } @@ -756,7 +762,7 @@ yp_first(char *indomain, char *inmap, ch struct dom_binding *ysd; struct timeval tv; int r; - + int retries = 0; /* Sanity check */ if (indomain == NULL || !strlen(indomain) || @@ -768,6 +774,11 @@ yp_first(char *indomain, char *inmap, ch YPLOCK(); again: + if (retries > MAX_RETRIES) { + YPUNLOCK(); + return (YPERR_RPC); + } + if (_yp_dobind(indomain, &ysd) != 0) { YPUNLOCK(); return (YPERR_DOMAIN); @@ -786,6 +797,7 @@ again: if (r != RPC_SUCCESS) { clnt_perror(ysd->dom_client, "yp_first: clnt_call"); _yp_unbind(ysd); + retries++; goto again; } if (!(r = ypprot_err(yprkv.stat))) { @@ -813,7 +825,7 @@ yp_next(char *indomain, char *inmap, cha struct dom_binding *ysd; struct timeval tv; int r; - + int retries = 0; /* Sanity check */ if (inkey == NULL || !strlen(inkey) || inkeylen <= 0 || @@ -826,6 +838,11 @@ yp_next(char *indomain, char *inmap, cha YPLOCK(); again: + if (retries > MAX_RETRIES) { + YPUNLOCK(); + return (YPERR_RPC); + } + if (_yp_dobind(indomain, &ysd) != 0) { YPUNLOCK(); return (YPERR_DOMAIN); @@ -846,6 +863,7 @@ again: if (r != RPC_SUCCESS) { clnt_perror(ysd->dom_client, "yp_next: clnt_call"); _yp_unbind(ysd); + retries++; goto again; } if (!(r = ypprot_err(yprkv.stat))) { @@ -874,7 +892,7 @@ yp_all(char *indomain, char *inmap, stru CLIENT *clnt; u_long status, savstat; int clnt_sock; - + int retries = 0; /* Sanity check */ if (indomain == NULL || !strlen(indomain) || @@ -883,6 +901,10 @@ yp_all(char *indomain, char *inmap, stru YPLOCK(); again: + if (retries > MAX_RETRIES) { + YPUNLOCK(); + return (YPERR_RPC); + } if (_yp_dobind(indomain, &ysd) != 0) { YPUNLOCK(); @@ -912,9 +934,10 @@ again: if (clnt_call(clnt, YPPROC_ALL, (xdrproc_t)xdr_ypreq_nokey, &yprnk, (xdrproc_t)xdr_ypresp_all_seq, &status, tv) != RPC_SUCCESS) { - clnt_perror(ysd->dom_client, "yp_all: clnt_call"); + clnt_perror(clnt, "yp_all: clnt_call"); clnt_destroy(clnt); _yp_unbind(ysd); + retries++; goto again; }