From nobody Sun Sep 10 16:41:23 2023 X-Original-To: current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RkFwj40wpz4sH9N for ; Sun, 10 Sep 2023 16:41:25 +0000 (UTC) (envelope-from des@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RkFwj2YVrz3ZZn; Sun, 10 Sep 2023 16:41:25 +0000 (UTC) (envelope-from des@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694364085; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pqf4eT6yrsksK/Xb+6EsWHRVApAiBbWMUXvQ78c1f0I=; b=oWbsQfBbUnN6Xl7KEpk6+aOwdoOA8gpe4Dypx28yDlPwYZkuFjeAxdiotmlDhm+v45iZFw cpG26/qeZOH3HEw16PN9aox9pLFjMDHYNr9ZTz2jhh1p8ZFR0ybIMaEAUKOUkKCn6Hyd2M MorF8IT+5MTlYfFuhx23SjftgGBbptZTi2IUZw0Iel/VK9OtKTHI53z/h5xSNiMeuXSvBw OpgSMuB7hXs1KX5UcVaAFPZZ7JYzb5rZAbRNyM7/g8mVs6QxbmnQ7ky7NMU9xROLm/alA0 tB5vfcULHxV0idM6yG30e8um2zYvm1ocruHWmiEwRi5uNsmWV2uZ/Hj4fyX5HQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694364085; a=rsa-sha256; cv=none; b=lP8QG4grEPcR90DjZaMVp2znADaBiN5kUIl/aUs7fUsdYh0tVzTItiJwhfuIWS2EOeDKr9 kMWqrof9WCsD4mmTn3QucqsD+j6U0v+XMQP7y0bocame1vRpye0fj3p4El0fqzC94geEIR /Bj0huv3uMVk8+7ih3Djel/s6UieNfWuMkrC0xkY9QXjtCRMJue5EZdtuefL2wHS2XrQ8F vT7KjocJzSwbFVHBlqXOix8msAohmibIMYV27/B9ablLuhXIt52Jl79qa0J71uC0Ip+3Kf Kkhc+RtfbqRrVy6SMXa5NnSQgy7/318bc3pelq0LgW8zQS1lgGxDEPsLb5lyRg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694364085; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pqf4eT6yrsksK/Xb+6EsWHRVApAiBbWMUXvQ78c1f0I=; b=Yh/07WENe2Bt3sBsSP6znGjULkfzFnmAZvkOLNaQyhNtVPTkR3Yz2ygkNlMruk5T9Pa/8S PHbpbjU+QwAC+hbGUviWzadj08xvmMs8lDJoa5Dz786s7twZdBDacjHwZkbogRCB3j9Vit LLCpdYjoL7iaSzG7cPSbmcGoP0HqJVFhHb4rAfK9Rr6/Aa0d7G9jEY2NKij0cnbd/z7jhd xpu5tcUHM1cgL8GJfNQtQc00o+VSf4ltKVlDT/Q8fNVvpHvEcdlyQxl3yD3pEaVIdvDjMT BZcplmiAX4X2sHU/1JAZZsYJhlPe++xFGCgqM3SPcQQX+IwJWEjot/Pa595SKw== Received: from ltc.des.no (unknown [IPv6:2001:4647:d671:0:36e8:94ff:feca:9834]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: des) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RkFwj0tGdz8m5; Sun, 10 Sep 2023 16:41:25 +0000 (UTC) (envelope-from des@freebsd.org) Received: by ltc.des.no (Postfix, from userid 1001) id 962E64ECB2; Sun, 10 Sep 2023 18:41:23 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Warner Losh Cc: Robert Clausecker , FreeBSD Current Subject: Re: sed in CURRENT fails in textproc/jq In-Reply-To: (Warner Losh's message of "Sun, 10 Sep 2023 09:53:03 -0600") References: <30a59ac0-28fd-f6ed-505c-9ef6d8e84fc3@tsoft.com> <86edj7qnia.fsf@ltc.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Sun, 10 Sep 2023 18:41:23 +0200 Message-ID: <861qf6q8uk.fsf@ltc.des.no> List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Warner Losh writes: > As for memchr, https://pubs.opengroup.org/onlinepubs/009696799/functions/= memchr.html > has no such permission to examine 'the entire buffer at once' nor any res= tirction > as to the length extending beyond the address space. I'm skeptical of you= r reading > that it allows one to examine all of [b, b + len), so please explain wher= e the standard > supports reading past the first occurance. C11 says: (7.24.4.1 =C2=A72) The memcmp function compares the first n characters = of the object pointed to by s1 to the first n characters of the object pointed to by s2. and (7.24.5.1 =C2=A72) The memchr function locates the first occurrence of c (converted to an unsigned char) in the initial n characters (each interpreted as unsigned char) of the object pointed to by s. The implementation shall behave as if it reads the characters sequentially and stops as soon as a matching character is found. The second sentence in the description of memchr() means a bogus length is allowed as long as we get a match before we read past the end of the object. There is no such provision for memcmp(), so calling memcmp() with a bogus length invokes UB. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@FreeBSD.org