From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Bindat can exhaust memory when unpacking to vector Date: Tue, 19 Mar 2024 17:08:41 -0400 Message-ID: References: <87pm16fnzv.fsf@iki.fi> <83zg09oa1v.fsf@gnu.org> <87a5s9m8ri.fsf@iki.fi> <83pm0q557b.fsf@gnu.org> <87a5mukmpj.fsf@iki.fi> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1836"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Petteri Hintsanen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 19 22:09:42 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rmgiM-0000HT-5x for ged-emacs-devel@m.gmane-mx.org; Tue, 19 Mar 2024 22:09:42 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmghV-0000V8-8i; Tue, 19 Mar 2024 17:08:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmghT-0000Ut-HR for emacs-devel@gnu.org; Tue, 19 Mar 2024 17:08:47 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmghR-0007Iu-Vr; Tue, 19 Mar 2024 17:08:47 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 53BA11000FC; Tue, 19 Mar 2024 17:08:44 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1710882522; bh=E49p3k9POYKGXTNQsntCR1ncIdYmRyLS7injcG4OeZ4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=eK8CVPUY2oH+BHsJgYL9xBoYH3XnWD7Wb/nmqi4AyIaPmuiN4aT8XdoUkV3LR2Iyj ZxZtJ3CuacNqdd3s1Reiff01690CEvkEeDNsUQ6ZzjSv9WhbIYmCLmfs3ylfqrSyvt UNKhOAiFQjMkjJKx9c5CvprFJ95l9ZMUcRgksZ2x5uoKaVOTYx30vUhWqt8o1qsSwg pCMuJA/+/dABm9doTi7QWSu+AhTAb7raUfiAxwiFUCjjRDQ2Yrhy4Jbvv+z2vJWMx8 Qg+7xBMFvxlb48A6fMkdzwvuLi3lJr/MM23Pm3leaE7Tdl6wLzpcetWxjaaKV27BSI qEqZWwRsdGOYg== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 81AFC100048; Tue, 19 Mar 2024 17:08:42 -0400 (EDT) Original-Received: from pastel (unknown [104.247.238.200]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 58FB81207EA; Tue, 19 Mar 2024 17:08:42 -0400 (EDT) In-Reply-To: <87a5mukmpj.fsf@iki.fi> (Petteri Hintsanen's message of "Tue, 19 Mar 2024 22:09:44 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317201 Archived-At: >> (defconst foo-bindat-spec >> (bindat-type >> (length uint 32) >> (data vec (bounded 1 length 1234)))) >> >> so we signal an error if the length is less than 1 or larger than 1234. > > Sure. But I'm not sure which kind of helpers would be the most > beneficial for general use. Like said, I don't have that many examples, > and for my few validation cases I have found the "unit type" to be good > enough. Same here. >>> I also played around with the idea of patching bindat.el itself to do >>> trivial checking against the input data size, like this: >>> [...] >> Actually, this is a nice solution, I think. >> It seems hypothetical enough that I think we should go with your patch. > Feel free to apply it in whatever form you want, if you think it is > appropriate. I did, thank you :-) >>> Checking should be optional and somehow programmable, perhaps >>> a separate "checked vec" type? (I don't have any good, concrete >>> ideas, sorry). >> I don't see the benefit of not-checking, to be honest. > I probably thought about efficiency here. In theory it can have an impact, but I think in practice it's hard to imagine a case where it will be significant. Stefan