From owner-svn-src-head@freebsd.org Wed Feb 5 16:10:09 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CE37324DDA5; Wed, 5 Feb 2020 16:10:09 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48CRNd4lMrz3D84; Wed, 5 Feb 2020 16:10:09 +0000 (UTC) (envelope-from markj@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9E28D5345; Wed, 5 Feb 2020 16:10:09 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 015GA9Ts028002; Wed, 5 Feb 2020 16:10:09 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 015GA9NU028001; Wed, 5 Feb 2020 16:10:09 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202002051610.015GA9NU028001@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 5 Feb 2020 16:10:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357576 - head/lib/libc/rpc X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/lib/libc/rpc X-SVN-Commit-Revision: 357576 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Feb 2020 16:10:09 -0000 Author: markj Date: Wed Feb 5 16:10:09 2020 New Revision: 357576 URL: https://svnweb.freebsd.org/changeset/base/357576 Log: Fix a use of an uninitialized pointer in xdr_rpcbs_rmtcalllist(). This appears to have been introduced in r173763. Also fix the confusing indentation that probably led to the bug in the first place. PR: 243759 Diagnosed by: martin@lispworks.com MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Modified: head/lib/libc/rpc/rpcb_st_xdr.c Modified: head/lib/libc/rpc/rpcb_st_xdr.c ============================================================================== --- head/lib/libc/rpc/rpcb_st_xdr.c Wed Feb 5 16:09:44 2020 (r357575) +++ head/lib/libc/rpc/rpcb_st_xdr.c Wed Feb 5 16:10:09 2020 (r357576) @@ -54,29 +54,28 @@ xdr_rpcbs_addrlist(XDR *xdrs, rpcbs_addrlist *objp) { struct rpcbs_addrlist **pnext; - if (!xdr_rpcprog(xdrs, &objp->prog)) { + if (!xdr_rpcprog(xdrs, &objp->prog)) { return (FALSE); - } - if (!xdr_rpcvers(xdrs, &objp->vers)) { + } + if (!xdr_rpcvers(xdrs, &objp->vers)) { return (FALSE); - } - if (!xdr_int(xdrs, &objp->success)) { + } + if (!xdr_int(xdrs, &objp->success)) { return (FALSE); - } - if (!xdr_int(xdrs, &objp->failure)) { + } + if (!xdr_int(xdrs, &objp->failure)) { return (FALSE); - } - if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { + } + if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { return (FALSE); - } + } - pnext = &objp->next; - - if (!xdr_pointer(xdrs, (char **) pnext, + pnext = &objp->next; + if (!xdr_pointer(xdrs, (char **) pnext, sizeof (rpcbs_addrlist), (xdrproc_t)xdr_rpcbs_addrlist)) { return (FALSE); - } + } return (TRUE); } @@ -86,86 +85,86 @@ xdr_rpcbs_addrlist(XDR *xdrs, rpcbs_addrlist *objp) bool_t xdr_rpcbs_rmtcalllist(XDR *xdrs, rpcbs_rmtcalllist *objp) { - int32_t *buf; struct rpcbs_rmtcalllist **pnext; + int32_t *buf; + pnext = &objp->next; if (xdrs->x_op == XDR_ENCODE) { - buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_rpcprog(xdrs, &objp->prog)) { - return (FALSE); + buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_rpcprog(xdrs, &objp->prog)) { + return (FALSE); + } + if (!xdr_rpcvers(xdrs, &objp->vers)) { + return (FALSE); + } + if (!xdr_rpcproc(xdrs, &objp->proc)) { + return (FALSE); + } + if (!xdr_int(xdrs, &objp->success)) { + return (FALSE); + } + if (!xdr_int(xdrs, &objp->failure)) { + return (FALSE); + } + if (!xdr_int(xdrs, &objp->indirect)) { + return (FALSE); + } + } else { + IXDR_PUT_U_INT32(buf, objp->prog); + IXDR_PUT_U_INT32(buf, objp->vers); + IXDR_PUT_U_INT32(buf, objp->proc); + IXDR_PUT_INT32(buf, objp->success); + IXDR_PUT_INT32(buf, objp->failure); + IXDR_PUT_INT32(buf, objp->indirect); } - if (!xdr_rpcvers(xdrs, &objp->vers)) { + if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { return (FALSE); } - if (!xdr_rpcproc(xdrs, &objp->proc)) { + if (!xdr_pointer(xdrs, (char **) pnext, + sizeof (rpcbs_rmtcalllist), + (xdrproc_t)xdr_rpcbs_rmtcalllist)) { return (FALSE); } - if (!xdr_int(xdrs, &objp->success)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->failure)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->indirect)) { - return (FALSE); - } - } else { - IXDR_PUT_U_INT32(buf, objp->prog); - IXDR_PUT_U_INT32(buf, objp->vers); - IXDR_PUT_U_INT32(buf, objp->proc); - IXDR_PUT_INT32(buf, objp->success); - IXDR_PUT_INT32(buf, objp->failure); - IXDR_PUT_INT32(buf, objp->indirect); - } - if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { - return (FALSE); - } - pnext = &objp->next; - if (!xdr_pointer(xdrs, (char **) pnext, - sizeof (rpcbs_rmtcalllist), - (xdrproc_t)xdr_rpcbs_rmtcalllist)) { - return (FALSE); - } - return (TRUE); + return (TRUE); } else if (xdrs->x_op == XDR_DECODE) { - buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_rpcprog(xdrs, &objp->prog)) { - return (FALSE); + buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_rpcprog(xdrs, &objp->prog)) { + return (FALSE); + } + if (!xdr_rpcvers(xdrs, &objp->vers)) { + return (FALSE); + } + if (!xdr_rpcproc(xdrs, &objp->proc)) { + return (FALSE); + } + if (!xdr_int(xdrs, &objp->success)) { + return (FALSE); + } + if (!xdr_int(xdrs, &objp->failure)) { + return (FALSE); + } + if (!xdr_int(xdrs, &objp->indirect)) { + return (FALSE); + } + } else { + objp->prog = (rpcprog_t)IXDR_GET_U_INT32(buf); + objp->vers = (rpcvers_t)IXDR_GET_U_INT32(buf); + objp->proc = (rpcproc_t)IXDR_GET_U_INT32(buf); + objp->success = (int)IXDR_GET_INT32(buf); + objp->failure = (int)IXDR_GET_INT32(buf); + objp->indirect = (int)IXDR_GET_INT32(buf); } - if (!xdr_rpcvers(xdrs, &objp->vers)) { + if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { return (FALSE); } - if (!xdr_rpcproc(xdrs, &objp->proc)) { + if (!xdr_pointer(xdrs, (char **) pnext, + sizeof (rpcbs_rmtcalllist), + (xdrproc_t)xdr_rpcbs_rmtcalllist)) { return (FALSE); } - if (!xdr_int(xdrs, &objp->success)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->failure)) { - return (FALSE); - } - if (!xdr_int(xdrs, &objp->indirect)) { - return (FALSE); - } - } else { - objp->prog = (rpcprog_t)IXDR_GET_U_INT32(buf); - objp->vers = (rpcvers_t)IXDR_GET_U_INT32(buf); - objp->proc = (rpcproc_t)IXDR_GET_U_INT32(buf); - objp->success = (int)IXDR_GET_INT32(buf); - objp->failure = (int)IXDR_GET_INT32(buf); - objp->indirect = (int)IXDR_GET_INT32(buf); - } - if (!xdr_string(xdrs, &objp->netid, RPC_MAXDATASIZE)) { - return (FALSE); - } - if (!xdr_pointer(xdrs, (char **) pnext, - sizeof (rpcbs_rmtcalllist), - (xdrproc_t)xdr_rpcbs_rmtcalllist)) { - return (FALSE); - } - return (TRUE); + return (TRUE); } if (!xdr_rpcprog(xdrs, &objp->prog)) { return (FALSE);