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=0.0 required=5.0 tests=none autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32548 invoked from network); 13 Feb 2021 05:55:14 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 13 Feb 2021 05:55:14 -0000 Received: from mimir.eigenstate.org ([206.124.132.107]) by 1ess; Fri Feb 12 22:43:45 -0500 2021 Received: from abbatoir.fios-router.home (pool-74-101-2-6.nycmny.fios.verizon.net [74.101.2.6]) by mimir.eigenstate.org (OpenSMTPD) with ESMTPSA id 8835ee46 (TLSv1.2:ECDHE-RSA-AES256-SHA:256:NO) for <9front@9front.org>; Fri, 12 Feb 2021 19:43:35 -0800 (PST) Message-ID: <10CE4A9EC513CE5FC11B0B0D5006E7C8@eigenstate.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit To: 9front@9front.org Date: Fri, 12 Feb 2021 19:43:34 -0800 From: ori@eigenstate.org In-Reply-To: <32B4F44886A8F86854EDDC8FF1699640@5ess.inri.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: full-stack CSS module Subject: Re: [9front] sam input line length limits Reply-To: 9front@9front.org Precedence: bulk Quoth sl@stanleylieber.com: > sam.h says: > > /* > * BLOCKSIZE is relatively small to keep memory consumption down. > */ > > and: > > #define BLOCKSIZE 2048 > > and: > > #define STRSIZE (2*BLOCKSIZE) > > is there a compelling reason to keep STRSIZE so small, in this day and > age? > > problem case: > > users trying to paste in long articles from websites. > > sl > I'd be in favor of bumping STRSIZE up a lot. It only seems to be used as a "sane upper bound" on string length, so changing the one place that uses it as a stack buffer and over to malloc should be safe. Here's an untested diff that bumps it to 512 megabytes. diff -r ce98610ce572 sys/src/cmd/sam/address.c --- a/sys/src/cmd/sam/address.c Wed Feb 10 15:42:18 2021 -0800 +++ b/sys/src/cmd/sam/address.c Fri Feb 12 19:41:41 2021 -0800 @@ -143,14 +143,16 @@ int filematch(File *f, String *r) { - char *c, buf[STRSIZE+100]; + char *c, *s; String *t; c = Strtoc(&f->name); - sprint(buf, "%c%c%c %s\n", " '"[f->mod], + s = smprint("%c%c%c %s\n", " '"[f->mod], "-+"[f->rasp!=0], " ."[f==curfile], c); + if(s == nil) + error(Etoolong); free(c); - t = tmpcstr(buf); + t = tmpcstr(s); Strduplstr(&genstr, t); freetmpstr(t); /* A little dirty... */ @@ -159,6 +161,7 @@ bufreset(menu); bufinsert(menu, 0, genstr.s, genstr.n); compile(r); + free(s); return execute(menu, 0, menu->nc); } diff -r ce98610ce572 sys/src/cmd/sam/sam.h --- a/sys/src/cmd/sam/sam.h Wed Feb 10 15:42:18 2021 -0800 +++ b/sys/src/cmd/sam/sam.h Fri Feb 12 19:41:41 2021 -0800 @@ -18,7 +18,7 @@ #define INFINITY 0x7FFFFFFFL #define INCR 25 -#define STRSIZE (2*BLOCKSIZE) +#define STRSIZE (512<<20) typedef long Posn; /* file position or address */ typedef ushort Mod; /* modification number */