From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <9front-bounces@9front.inri.net> X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from 9front.inri.net (9front.inri.net [168.235.81.73]) by inbox.vuxu.org (Postfix) with ESMTP id DA9EA240AF for ; Tue, 23 Jan 2024 08:45:33 +0100 (CET) Received: from mail-lf1-f51.google.com ([209.85.167.51]) by 9front; Tue Jan 23 02:44:12 -0500 2024 Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-50f1c524010so4002279e87.3 for <9front@9front.org>; Mon, 22 Jan 2024 23:44:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705995849; x=1706600649; darn=9front.org; h=content-transfer-encoding:to:subject:from:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=Wij/VCxjOYI0GnSyK6CYbSZPgSmiHvyIRmaPNJhy6gM=; b=g5+GbNsF/iUVQ/u8Uk27kEgkE4L6pbEIreObSeMN+dXnj+fR79M5Ve0H6Hu2I89s4j uMgF9WFtMXsnOE+2nrBx9hg7UghwgFlx+KOhL1msRRyR6JPmipPUXYF7y0KiJgr3lX0D /zxIT3YDhGqMXb8eEK4/QV9v2umluwjRjRgRlqDrgNJM1MwM309D/SBgwTc504iwUnXD E7W+64SFojVZanh2x5eTSpk2RcgFfvRgH9poAUAPtVh7auYPqOlL1ZAFLQDrQuPvRKME Z2wCdQYD6Dxh+h2LuRjOG8vI3B1xry2in5lW00oY90N957n+gfNjXZNPJg9h2uFcb6y4 G3zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705995849; x=1706600649; h=content-transfer-encoding:to:subject:from:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Wij/VCxjOYI0GnSyK6CYbSZPgSmiHvyIRmaPNJhy6gM=; b=V2jEiG0GIK+f3Mdjj1DZKKGdv6Cwx/OvDc/k9t5QYFYeDIVsxH+VfFaO/ycUN61jZT 6z1N7nRCaTnh0SoT9RqMrRn9XlRITyyR2Qk/CDYKp0pNpJi8tUGRxstuenPhKM3/pj1U /FEk/GtTrQP+f9UaDNN+bE2GqvYdWiy4lOw8vh/UvkNdtT0QQ7SfLeayGmJi2yKmTPXz 33jPg4v5FP1UQlBROwhgqsqjRtY0amZtJCp1P9l7TeIGLzKxi987qeRDOiRL0xM/XCGY Zt3Y2LhcJ4P+RbWsEdjBGM83475M40MlYvyb7Tusd/l/JtDXGMJbgE8Z4qBW8LDjPzvo ZIEA== X-Gm-Message-State: AOJu0YztjHBzHCub4wnz4yxHVC+Bc1KpVTq6P4i1N+RhD2iCMWQ+xk0I rsBjbg5jlvC2foFj+8nXktxwU5IVBuN099S7vNepcIONrKy5OW/kJYBbw6oI X-Google-Smtp-Source: AGHT+IHffIu4jY37qlpPWCCVZXFYPyR9tAZSaGbRV8gnETxuu3vEmlGo7VTKaSGpLsWUO0IXCaoVDQ== X-Received: by 2002:ac2:42d0:0:b0:510:56e:68ad with SMTP id n16-20020ac242d0000000b00510056e68admr166207lfl.122.1705995848669; Mon, 22 Jan 2024 23:44:08 -0800 (PST) Received: from ?IPV6:2001:14ba:6843:2700:30ec:1ab4:af9e:385f? (dqbbwrybt9tqnln80jbst-3.rev.dnainternet.fi. [2001:14ba:6843:2700:30ec:1ab4:af9e:385f]) by smtp.gmail.com with ESMTPSA id h23-20020a19ca57000000b0050ee3e540e4sm2282524lfj.65.2024.01.22.23.44.08 for <9front@9front.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jan 2024 23:44:08 -0800 (PST) Message-ID: Date: Tue, 23 Jan 2024 09:44:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Kristo To: 9front@9front.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: mobile package deep-learning interface-aware control Subject: [9front] [PATCH] awk: don't write an extra NUL past the end of a block Reply-To: 9front@9front.org Precedence: bulk When splitting a record into individual fields awk seems to write an extra NUL at the end, which is not an issue when a record fits in the default buffer. However, with larger records the buffer is allocated to length of the string + 1, meaning that the extra NUL goes past the end of the block and causes a "mem user overflow" panic. diff 26c21f9b5d06296d13f40b53de14e22007e189c2 uncommitted --- a/sys/src/cmd/awk/lib.c +++ b/sys/src/cmd/awk/lib.c @@ -287,7 +287,6 @@ while (*r != ' ' && *r != '\t' && *r != '\n' && *r != '\0'); *fr++ = 0; } - *fr = 0; } else if ((sep = *inputFS) == 0) { /* new: FS="" => 1 char/field */ for (i = 0; *r != 0; r += w) { char buf[UTFmax + 1]; @@ -320,7 +319,6 @@ if (*r++ == 0) break; } - *fr = 0; } if (i > nfields) FATAL("record `%.30s...' has too many fields; can't happen", r);