From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.emacs.help Subject: Printf and quoting in general, SQL injection in particular [was: Emacs Modular Configuration: the preferable way] Date: Mon, 21 Jun 2021 23:15:47 +0200 Message-ID: <20210621211547.GA12274@tuxteam.de> References: <87pmwgdiyj.fsf@zoho.eu> <83y2b3tq07.fsf@gnu.org> <871r8vcrnm.fsf@posteo.net> <20210621141148.GA29347@tuxteam.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7JfCtLOvnd9MIVvH" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15329"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.5.21 (2010-09-15) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 21 23:16:51 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1lvRHn-0003pa-9m for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 21 Jun 2021 23:16:51 +0200 Original-Received: from localhost ([::1]:43962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lvRHm-000160-7m for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 21 Jun 2021 17:16:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lvRGq-0000Nw-87 for help-gnu-emacs@gnu.org; Mon, 21 Jun 2021 17:15:52 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:48901) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.90_1) (envelope-from ) id 1lvRGn-0002nP-NZ for help-gnu-emacs@gnu.org; Mon, 21 Jun 2021 17:15:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date; bh=m/TCl2JwAsm9Gw5nK1R0b7INh6fopTSv3RIP1iPi5l8=; b=Si5lywrBetPqq/QHY0kSDtsJVQfHJjqbndJBYmaYNmZ3lAuvB5xtqA+e2TMqD89CTjA/zQIlXdVK/g3qTg5o7NHiApjLiLbBea2N9skWTlVYU8S/K7VxDVA1M0KcotOgdeZXyEWfV5oK3iAU2pVrzeu4AV9e2QJjLgk/I/eHtmV04WTF3exJku+hyxRi77fkeRd0j5llfxw/j5ZfI4RkoS/W+y5+xL0L2lQGneOdrmBRFPoQJ6rgisRY6WWzajgMzV+oSyXEUR/E23krKObYGPg2URGUchpYOOREaHhFy4Zq0QsdieYUr8u7QG5dBLhIusLH5W+YAGwmXVf/i+yyiQ==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1lvRGl-0003ec-DC for help-gnu-emacs@gnu.org; Mon, 21 Jun 2021 23:15:47 +0200 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:131162 Archived-At: --7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 21, 2021 at 11:36:25PM +0300, Jean Louis wrote: > * tomas@tuxteam.de [2021-06-21 17:12]: > > But you still see extremely bad habits "out there" which wouldn't be > > necessary these days -- because, well, they are "out there" (for > > example: assebling SQL queries with sprintf [1]). They take a life > > of their own :-) > >=20 > > Cheers > > [1] https://xkcd.com/327/ >=20 > Your small reference is definitely a possible danger if SQL input is > anyhow exposed [...] M< hint was rather a metaphor: using string operations on things that aren't really strings (in the original case: file system paths) can lead to surprising results. > the danger mentioned on the funny comic is practically non-existent as > it will never take place on my side [...] But your side is not "the world", and therefore Eli's warning was spot-on. Someone will browse the mail archives and copy your solution without knowing the dangers. > I am heavy user of the Emacs package: emacs-libpq @ Github > https://github.com/anse1/emacs-libpq No idea and no bandwidth to read it all. If you are tied to PostgreSQL (a good choice, I'd say), consider using prepared queries: they do what client-side template expansion (even the careful kind, with unescaping and all), and I'd expect them to do it much better, since PostgreSQL knows its own syntax best. Cheers - t --7JfCtLOvnd9MIVvH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAmDRAYMACgkQBcgs9XrR2ka4rACfV2bHKeirukfT7Us8NGSxZXPq QwAAnjiZEpvjOckT5o4uuNVQSSD3dL9T =cOmA -----END PGP SIGNATURE----- --7JfCtLOvnd9MIVvH--