From owner-dev-commits-src-all@freebsd.org Mon Feb 8 15:18:10 2021 Return-Path: Delivered-To: dev-commits-src-all@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 F25A45365F3; Mon, 8 Feb 2021 15:18:10 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DZ8mL6MNpz3t7n; Mon, 8 Feb 2021 15:18:10 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qv1-xf2f.google.com with SMTP id 2so7103294qvd.0; Mon, 08 Feb 2021 07:18:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+YteNDmpsaz1o1ARDbTOhZH29i8EYrZtuwgFSJ0ZW1I=; b=W8+UCiThjgPTNv2rwG9Z+MjbHZMZB2c5quVtUfYM/beZNmpl8KQIQV2+JIEHzTiv2b W+5SAhHaCuaQxfRtKbemmTrkpeC1vnMLQ2hnRSKKQ1nnFGRcCfL0VLeuuZIoBUZxrDce s4oDH77pqTJZ2uwupWsGfehW2Geaur7auTmFxjUT15iQdKpkU6fyw+hl4Brv4fhR7a0W kmzsQjaq4NUM5wKCZt2mfKS4B7cS8ptZVQe1yjd5UDLGMad0UW6AaajiNEzg1qWFo7Sy 4Ru5GZYYnhHcrAuZSinjwSVKeaL0oDKxAj4GJgyIl0VOsy1sjBAWL8oIKhTIXij/4VVt 0fmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=+YteNDmpsaz1o1ARDbTOhZH29i8EYrZtuwgFSJ0ZW1I=; b=GkUzVsDoTPOgA8oR26mSFzKJHeq1s/coyqfY3dIMJ05R7xOg7urET8DZOQnU2zZZtF jBc3p/BO/ClO/7OWxr2c7S2YHT4IEoCFWQledkGabhWHmGrIs6GsiBoA5Te2NrZyCoTL HCoGMaOIIMh1xeIM+OhKwtqhEDbi9NaZ1Xps+V8wLunz0qU67tB9te5dYPXXQ+j1aeQ/ 97MLgtlfS1jkYA1eIyAjwFpPQj43/zv+oPqbmnsR5mG0yj5M/uYa0bkV8FkYoKCKwvy9 00NDLmq1nbIQsm4MYOBUHyG1LfnC8Z15Mm9AOfVzNBlEFmgXAgTDrTvoe9OpJGUY4WxX E/XQ== X-Gm-Message-State: AOAM5314LVnVh36LFWA8OcMCrPHll7rp0S/RTEqKOd9Ne4zeCl0ufq1H opUxa4FktVW5bIS0/S3o0p77S+Ey9i4= X-Google-Smtp-Source: ABdhPJynxMJVxLiL/4cS3Scm1rIjVTw643ScvBepgzb54/5/xd7QQZkCchRqFy7IgVzUa3chwfKk6A== X-Received: by 2002:a0c:b66c:: with SMTP id q44mr16418676qvf.3.1612797489204; Mon, 08 Feb 2021 07:18:09 -0800 (PST) Received: from raichu ([142.126.164.150]) by smtp.gmail.com with ESMTPSA id n20sm5874747qke.128.2021.02.08.07.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 07:18:08 -0800 (PST) Sender: Mark Johnston Date: Mon, 8 Feb 2021 10:18:06 -0500 From: Mark Johnston To: Lutz Donnerhacke Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 45d75e3ac3fb - main - netgraph/ng_base: Allow larger BINARY2ASCII conversions Message-ID: References: <202102081335.118DZB5F024911@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202102081335.118DZB5F024911@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4DZ8mL6MNpz3t7n X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Feb 2021 15:18:11 -0000 On Mon, Feb 08, 2021 at 01:35:11PM +0000, Lutz Donnerhacke wrote: > The branch main has been updated by donner: > > URL: https://cgit.FreeBSD.org/src/commit/?id=45d75e3ac3fb5bf8230ca28dc09b48c6e5ed7a4f > > commit 45d75e3ac3fb5bf8230ca28dc09b48c6e5ed7a4f > Author: Lutz Donnerhacke > AuthorDate: 2021-02-07 21:07:34 +0000 > Commit: Lutz Donnerhacke > CommitDate: 2021-02-08 13:31:58 +0000 > > netgraph/ng_base: Allow larger BINARY2ASCII conversions > > Allocate the necessary memory for the conversion dynamically starting > with a value which is sufficient for almost all normal cases. Is there some upper bound on the length of the input message? If not, a sufficiently large input looks like it could cause an infinite loop by triggering overflow in the bufSize *= 2 calculation. I also wonder why the same change was not made for ASCII2BINARY. > > PR: 187835 > Reviewed by: kp > Differential Revision: https://reviews.freebsd.org/D23840 > --- > sys/netgraph/ng_base.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c > index 6ab39421b255..63bc251f52f9 100644 > --- a/sys/netgraph/ng_base.c > +++ b/sys/netgraph/ng_base.c > @@ -2771,7 +2771,7 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook) > > case NGM_BINARY2ASCII: > { > - int bufSize = 20 * 1024; /* XXX hard coded constant */ > + int bufSize = 1024; > const struct ng_parse_type *argstype; > const struct ng_cmdlist *c; > struct ng_mesg *binary, *ascii; > @@ -2785,7 +2785,7 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook) > error = EINVAL; > break; > } > - > +retry_b2a: > /* Get a response message with lots of room */ > NG_MKRESPONSE(resp, msg, sizeof(*ascii) + bufSize, M_NOWAIT); > if (resp == NULL) { > @@ -2827,9 +2827,13 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook) > if (argstype == NULL) { > *ascii->data = '\0'; > } else { > - if ((error = ng_unparse(argstype, > - (u_char *)binary->data, > - ascii->data, bufSize)) != 0) { > + error = ng_unparse(argstype, (u_char *)binary->data, > + ascii->data, bufSize); > + if (error == ERANGE) { > + NG_FREE_MSG(resp); > + bufSize *= 2; > + goto retry_b2a; > + } else if (error) { > NG_FREE_MSG(resp); > break; > } > _______________________________________________ > dev-commits-src-all@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all > To unsubscribe, send any mail to "dev-commits-src-all-unsubscribe@freebsd.org"