From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.devel Subject: Re: master d995429e7bc: Use SBYTES instead of strlen in treesit.c Date: Wed, 24 Jul 2024 14:02:26 +0200 Message-ID: <4044D6BB-3529-47A8-B94B-B2D0A6F3873C@gmail.com> References: <172164369582.30827.14373383262408294645@vcs2.savannah.gnu.org> <20240722102136.6C9D6C3534A@vcs2.savannah.gnu.org> <87o76pyb5h.fsf@yahoo.com> <8634o1br4c.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16773"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Yuan Fu , luangruo@yahoo.com, emacs-devel@gnu.org To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 24 14:03:25 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 1sWaiJ-0004CW-Tr for ged-emacs-devel@m.gmane-mx.org; Wed, 24 Jul 2024 14:03:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWahY-0001Bj-9u; Wed, 24 Jul 2024 08:02:36 -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 1sWahU-0000w0-KX for emacs-devel@gnu.org; Wed, 24 Jul 2024 08:02:32 -0400 Original-Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWahS-0002VW-G9; Wed, 24 Jul 2024 08:02:32 -0400 Original-Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52f01993090so4856428e87.2; Wed, 24 Jul 2024 05:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721822548; x=1722427348; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=aYUfz/v5cW4DkDqocp3HiG8wBulpqYAiv1znGyfVDzw=; b=DYVXWZBZhMDPretrsCVamW6z/uAcdh0sfQiS5R9tsLz/gG0X4JeFVJDujOCkxuIeGH f9XfTCJMymtRsp2IAfXTt6PUcyVYRxuwKhqvG2jpZjPNy3O9xt2fHtWEMkKcnNRg4UeH wg0ndc145SmYqEiXKA9YiU7rMvB6PqB752NqNGg8aDvFyLOqOf+DMLJhzFfaDgteme0M sjeFIzAedF02U9XI6DCuTMr+H3oqWaFf3DVmnGovm5kN1/5YrH+TIsnEiHtfgTL7IwT4 zOwri46nR84GhQ4+aUf+5kZeV2m6tiIhkJnkx+pr7UHePO4ThC+A+79BTOYAomxh8ixG +Q6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721822548; x=1722427348; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=aYUfz/v5cW4DkDqocp3HiG8wBulpqYAiv1znGyfVDzw=; b=WhQo8+b93p/JSS9kbBA3w35amas2uZ+R0FnOMu9YaMjR5lrPj6j2gTuAfBVwc7bVpk lPLqwSIoUqxBXGYjeJ55zovOdTU5UwmQEO0Kydf2bbCLS4daTOGAm0SfPsOeRYuoV56v H7FQQWJO8jXrrFX0m2/21E+21w4kf4LwU55jHPaubCKZ+Ol1ZopLPQjj3wESKoqiQ4qZ FeTb60Xj8qU6TJ3++xXY3CRQEWKkxWMKhBlcWW5ZOtmWzRAQK9mdVdIoVwmIkIt2CiM/ 17QkvKMdyO/ir3d3I2BBdbixmxfgq5t5lRarSpwe5+5jkwbbHWcVKWi+YmpP3SbKWlkE Wl5Q== X-Forwarded-Encrypted: i=1; AJvYcCUDBGeE65salDT/Mvk2FcyDIf6aHO6erFPzLJU5tyrSRI4Sqp+OtqQkjWuKt6cIyC48uuDjqSyGqQixek2uuiGHcY3/ X-Gm-Message-State: AOJu0Yy5QyEMWbtOyWQoLxQGWCronbAMs4QwecKg6UGbU3T1vSQf0VdS CoScLMS/7GIu168VArSoMiZln2dRMyyVkv5s8qCQhsS2TvMtBtVs X-Google-Smtp-Source: AGHT+IEeYwmyo0WkwNZN/dA+R8zzjui+m+lRctl/nTmRyUxHgTdcDPe7pPExd8CJpKWjfgyrjGaMSQ== X-Received: by 2002:a05:6512:3d8d:b0:52e:f950:31e9 with SMTP id 2adb3069b0e04-52fcda21bd2mr1817038e87.4.1721822547517; Wed, 24 Jul 2024 05:02:27 -0700 (PDT) Original-Received: from smtpclient.apple (c188-150-191-82.bredband.tele2.se. [188.150.191.82]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52eff381fb7sm1367674e87.152.2024.07.24.05.02.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jul 2024 05:02:26 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.15) Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=mattias.engdegard@gmail.com; helo=mail-lf1-x133.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:322043 Archived-At: 24 juli 2024 kl. 13.33 skrev Stefan Kangas : > It's not about what we get from tree-sitter, but what we pass to it. >=20 > I recently changed calls to ts_node_child_by_field_name and > treesit_query from using strlen for the length argument to using = SBYTES. > But that meant that we now pass a length of 7 instead of 3 for Lisp > strings like "abc\^@def". The question is if tree-sitter will accept > that. Yes, your change makes sense and I have no reason to object to it. For that matter, the query is supposed to be a string in TS S-exp = format, and we serialise the query passed to `treesit-query-capture` etc = into that format. If the query is a string then it's supposed to be = well-formed already, of course, but that doesn't seem to be a common = mode of usage. But if you ask whether an attacker could somehow use NULs in the text = being parsed as a way to subvert tree-sitter and/or Emacs, then I cannot = reply with any confidence. Too many moving parts and too little = compartmentalisation for that.