From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21503 invoked from network); 12 Jul 2021 16:28:57 -0000 Received: from tb-ob21.topicbox.com (173.228.157.67) by inbox.vuxu.org with ESMTPUTF8; 12 Jul 2021 16:28:57 -0000 Received: from tb-mx1.topicbox.com (tb-mx1.nyi.icgroup.com [10.90.30.61]) by tb-ob21.topicbox.com (Postfix) with ESMTP id E6F8E1D7C5 for ; Mon, 12 Jul 2021 12:28:54 -0400 (EDT) (envelope-from bounce.mM36acff490ae45918672f52bd.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx1.topicbox.com (Postfix, from userid 1132) id C722C2CA2D16; Mon, 12 Jul 2021 12:28:54 -0400 (EDT) ARC-Authentication-Results: i=2; topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=quarantine policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=quarantine,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=date:to:subject:in-reply-to:message-id :references:mime-version:content-type:from:list-help:list-id :list-post:list-subscribe:reply-to:content-transfer-encoding :list-unsubscribe; s=sysmsg-1; t=1626107334; bh=aTE+g30PxWQxXyB5 ScRih314rSNi5S3UYJuuhkxlnbk=; b=BbCRCyCMOIq11tYMO0J9cRqWRhL24EVE XE45Zgb1AkRNp/UBdyNWn69qDRTApPv715RBefqEpqn3pDXpG+UX7QOQHJGEYsbP J9F5sJi8J9jZgDm3zw6vvPusYZurT5L0+H6Jq1UiTzkhgNtXZgWd33WGE2nCmZzO AOhAW+aM2qQ= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1626107334; b=Q7gvxUEDHaIRVKnpcuHL4M2dRd7/iiEB9C4iuWjVd/hFratUlQ pXmLy0NQg1DYwVBuSeZ4PbTUYVaYAqtz5zDF4uC/I78fDK2djCTy/c8eOPGatw1R DtkdEn/9I09K17Y8RwfVvikDzZpuMUJFKHn3elA9lhOEMmu0FHWIluRTw= Authentication-Results: topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=quarantine policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=quarantine,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) X-Received-Authentication-Results: tb-mx1.topicbox.com; arc=none (no signatures found); bimi=none (No BIMI records found); dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=quarantine policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=quarantine,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; iprev=pass smtp.remote-ip=205.166.94.24 (mx.sdf.org); spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mx.sdf.org policy.ptr=mx.sdf.org; x-return-mx=pass header.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-return-mx=pass smtp.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=9fans.net; h=date:to :subject:in-reply-to:message-id:references:mime-version :content-type:from:list-help:list-id:list-post:list-subscribe :reply-to:content-transfer-encoding:list-unsubscribe; s=dkim-1; bh=ZZNxDIYk9OSHoiUs1vZjyE6Pa/Gst3VBPAWK6bIz3Is=; b=MVD8jmAzbqZ0 YBWN8BT2KlEPL27IvHJdW+NTyrWqFjOr9abgiKNV+pZjn6OJGr3a7S+6OVSgoNIV M2VC5kHdfryh9GYkw8I80NkIVXzOWy9fYTC8nTu950Fv3qR75IjJBB/DIPQIIv+H 7dD2pKJO8+EZgzxlXY3GUYfMfqFzhX4= Received: from tb-mx1.topicbox.com (localhost.local [127.0.0.1]) by tb-mx1.topicbox.com (Postfix) with ESMTP id 237FB2CA290A for <9fans@9fans.net>; Mon, 12 Jul 2021 12:28:45 -0400 (EDT) (envelope-from adr@SDF.ORG) Received: from tb-mx1.topicbox.com (localhost [127.0.0.1]) by tb-mx1.topicbox.com (Authentication Milter) with ESMTP id D6E8C35ABEA; Mon, 12 Jul 2021 12:28:45 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1626107325; b=W/n0EjTk40zztbH9ONOxgec5u/ZgbOLzxUtFc5T6WXqHPKfjSn DeaAG4U9Qsm5O8Fs2+Ou/qSHMyk6bQPbPOHIpEGxkVwQWNr6Xzkt2OPB3CHAVkEy KhB2YCjejwa+oiV1T+6o8H13Dd/8ghh6vRGdUhl0j77aTxlI1Ut4VS87WSxOqwwL yg3T7oAhvnHodAciSiVT5JV32O8rWnTKyleRdSpYGV0csRNGTFWdBpumHlNWUTIN nJMqp/bhnlij0LQx8Mc+g+rrjQSd19PXXxunoiMzBcCZcBGQe3ic0C6N0Jtdnb3R kXRAcOm47pEy8nDY/ud+p0B8CsyR7YdP4aUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=date:from:to:subject:in-reply-to:message-id :references:mime-version:content-type; s=arcseal; t=1626107325; bh=fW3XMPebjjljs6uRelL3VrJhymLL3oSOC+AB1uU7S58=; b=l6hL5I2d+6fT rtwuxKuYuPdkTXqT8QmEQmitAyp0ndULqp/PlbIK5yrMpzQeaVCckrQILFvEAbuz Kpbt+Kwxog+6L4HLBY5Kq/l81MK/wIUS7t7EjOxEkIHYF/EI5lf0qYNP0JYCWox7 HWL7U276G7VekfsQXxP2FUDti6L/n5xzUbmd71vVMe3UaYw3qvtnlFmtEZeMUl5s jqkKiUwd0Dq+WqP8KqHPOkxqbeJ8rVx9XugX/yedCBJ48160ZX3bGZkdo5WCqcjd d1UVxOw5zN32xrXY72/gkeTO5jCCc/8aJgJG7su5FgU6tx7KWw2BidrU9YzMIyeW 4WXO5IZSJQ== ARC-Authentication-Results: i=1; tb-mx1.topicbox.com; arc=none (no signatures found); bimi=none (No BIMI records found); dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=quarantine policy.published-subdomain-policy=quarantine policy.applied-disposition=none policy.evaluated-disposition=none (p=quarantine,sp=quarantine,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; iprev=pass smtp.remote-ip=205.166.94.24 (mx.sdf.org); spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mx.sdf.org policy.ptr=mx.sdf.org; x-return-mx=pass header.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-return-mx=pass smtp.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 X-ME-VSCause: gggruggvucftvghtrhhoucdtuddrgedvtddruddvgdellecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffujg fkfhggtgesthdtredttddtvdenucfhrhhomheprggurhcuoegrughrsefufffhrdfqtffi qeenucggtffrrghtthgvrhhnpeekhedtveffheevhfdtgefhhefgveelvedujeetjedthe duvdefvdekgedtfffhffenucfkphepvddthedrudeiiedrleegrddvgedpvddthedrudei iedrleegrdduieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpe dvtdehrdduieeirdelgedrvdegpdhhvghlohepmhigrdhsughfrdhorhhgpdhmrghilhhf rhhomhepoegrughrsefufffhrdfqtffiqe X-ME-VSScore: 0 X-ME-VSCategory: clean Received-SPF: pass (sdf.org: 205.166.94.24 is authorized to use 'adr@SDF.ORG' in 'mfrom' identity (mechanism 'ip4:205.166.94.0/24' matched)) receiver=tb-mx1.topicbox.com; identity=mailfrom; envelope-from="adr@SDF.ORG"; helo=mx.sdf.org; client-ip=205.166.94.24 Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tb-mx1.topicbox.com (Postfix) with ESMTPS for <9fans@9fans.net>; Mon, 12 Jul 2021 12:28:44 -0400 (EDT) (envelope-from adr@SDF.ORG) Received: from sdf.org (IDENT:adr@sdf.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 16CGShX1012965 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for <9fans@9fans.net>; Mon, 12 Jul 2021 16:28:43 GMT Received: from localhost (adr@localhost) by sdf.org (8.15.2/8.12.8/Submit) with ESMTP id 16CGShWt029077 for <9fans@9fans.net>; Mon, 12 Jul 2021 16:28:43 GMT Date: Mon, 12 Jul 2021 16:28:43 +0000 (UTC) To: 9fans <9fans@9fans.net> Subject: Re: [9fans] pngread: alloc chunk's length In-Reply-To: Message-ID: <625366cf-4157-435c-4f87-e176eb3c9d66@SDF.ORG> References: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8"; format="flowed" Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: 3d181f00-e32e-11eb-bf72-e205f8a26e59 Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UNGE3MTRlZDE0YzUwNzY3YS1NMzZhY2ZmNDkwYWU0NTkxODY3MmY1?= =?UTF-8?B?MmJkPg==?= From: "adr via 9fans" <9fans@9fans.net> List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> Content-Transfer-Encoding: quoted-printable List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:M36acff490ae45918672f52bd:1:eAv2_6ZmBKDFlUBaAm_iE-WEyKuDz83q2PCy5SoVfIY On Mon, 12 Jul 2021, ori@eigenstate.org wrote: > Why not make getchunk allocate? Somethign like: >=20 > --- > //.git/fs/object/e8259861da3a55c03491904e4d11c5c15b7577c5/tree/sys/src/cm= d/jpg/readpng.c > +++ sys/src/cmd/jpg/readpng.c > @@ -94,7 +94,7 @@ > } > > static int > -getchunk(Biobuf *b, char *type, uchar *d, int m) > +getchunk(Biobuf *b, char *type, uchar **d) > { > uchar buf[8]; > ulong crc =3D 0, crc2; > @@ -103,11 +103,10 @@ > if(Bread(b, buf, 8) !=3D 8) > return -1; > n =3D get4(buf); > + *d =3D pngmalloc(n, 0); > memmove(type, buf+4, 4); > type[4] =3D 0; > - if(n > m) > - sysfatal("getchunk needed %d, had %d", n, m); > - nr =3D Bread(b, d, n); > + nr =3D Bread(b, *d, n); > if(nr !=3D n) > sysfatal("getchunk read %d, expected %d", nr, n); > crc =3D blockcrc(crctab, crc, type, 4); > @@ -131,7 +130,7 @@ > Again: > z->p =3D z->buf; > z->e =3D z->p; > - n =3D getchunk(z->io, type, z->p, IDATSIZE); > + n =3D getchunk(z->io, type, &z->p); > if(n < 0 || strcmp(type, "IEND") =3D=3D 0) > return -1; > z->e =3D z->p + n; > > Hi Ori, I thought that it would be a good idea to have a separate function to just get the size without squeezing the fs through all the chunk, it could be useful in the future. getchunk() could call it, but I didn't see the point. I imagine that this is not a complete patch but a suggestion, but anyway remember that you don't need z->buf any more, and don't forget to free z->p for the next iteration. By the way after revisiting readpng.c I noticed that I checked for a negative value of the IHDR chunk length, better do like in the original code: [...] n =3D chunklen(b); if(n < 13) sysfatal("missing IHDR chunk"); [...] Regards, adr. ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/T4a714ed14c50767a-M36acf= f490ae45918672f52bd Delivery options: https://9fans.topicbox.com/groups/9fans/subscription