From unknown Sat Jun 21 10:36:53 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#50155 <50155@debbugs.gnu.org> To: bug#50155 <50155@debbugs.gnu.org> Subject: Status: don't use the conversion specifier %n in emacsclient Reply-To: bug#50155 <50155@debbugs.gnu.org> Date: Sat, 21 Jun 2025 17:36:53 +0000 retitle 50155 don't use the conversion specifier %n in emacsclient reassign 50155 emacs submitter 50155 Omar Polo severity 50155 normal tag 50155 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 21 17:38:20 2021 Received: (at submit) by debbugs.gnu.org; 21 Aug 2021 21:38:20 +0000 Received: from localhost ([127.0.0.1]:37962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHYh2-0008Kh-F3 for submit@debbugs.gnu.org; Sat, 21 Aug 2021 17:38:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:52696) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHYh0-0008KZ-Nh for submit@debbugs.gnu.org; Sat, 21 Aug 2021 17:38:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHYh0-0007hz-Fn for bug-gnu-emacs@gnu.org; Sat, 21 Aug 2021 17:38:18 -0400 Received: from mail.omarpolo.com ([144.91.116.244]:57173) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHYgx-0003Zt-KP for bug-gnu-emacs@gnu.org; Sat, 21 Aug 2021 17:38:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omarpolo.com; s=20200327; t=1629581887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=duaCSGoFjVxMW6XiEVy4rTH0XRopYuHAjXtbWchNBZc=; b=rCZRLKLeoZE0ybtZxoQkbKKngBHAAalvvAlfnQRt2DQcYy9xprJehdWAjc+p89+hCMUG56 wao3DmTlgnjJI42pB6IsFvaNzzwgz7uJB4glRzgGGLUzoZwTXaZtbEuQ5FArU5iLmi+lTm k67okOzSoqxQ4NYc+tz5r8FoYxtCvUY= Received: from localhost (host-79-25-237-90.retail.telecomitalia.it [79.25.237.90]) by mail.omarpolo.com (OpenSMTPD) with ESMTPSA id d61752f9 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Sat, 21 Aug 2021 23:38:05 +0200 (CEST) Received: from venera (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 4036a31c for ; Sat, 21 Aug 2021 23:38:04 +0200 (CEST) From: Omar Polo To: bug-gnu-emacs@gnu.org Subject: don't use the conversion specifier %n in emacsclient Date: Sat, 21 Aug 2021 23:38:04 +0200 Message-ID: <87zgtaxyv7.fsf@omarpolo.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=144.91.116.244; envelope-from=op@omarpolo.com; helo=mail.omarpolo.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain Tags: patch Hello, The usage of the %n conversion specifier for printf(3) is widely discouraged (see [0] for instance). The OpenBSD libc in particular logs to syslog every time an application tries to use %n. Now, in this specific case it's used in a completely safe manner, but avoiding it seems pretty easy. Another option would be char *emacsdirend = strchr(sockname + tmpdirlen + 1, '/'); but I'm not sure it would be cleaner. Thanks, Omar Polo [0]: https://man.bsd.lv/Linux-5.06/printf.3#BUGS In GNU Emacs 28.0.50 (build 11, x86_64-unknown-openbsd6.9, X toolkit, cairo version 1.16.0, Xaw scroll bars) of 2021-08-17 built on venera Windowing system distributor 'The X.Org Foundation', version 11.0.12010000 System Description: OpenBSD venera 6.9 GENERIC.MP#158 amd64 Configured using: 'configure --prefix=/home/op/opt/emacs --with-x-toolkit=lucid CC=cc' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-don-t-use-n.patch >From 18585de41f2d0dc442fe2122c25165f07913c974 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Sat, 21 Aug 2021 21:32:22 +0000 Subject: [PATCH] don't use %n --- lib-src/emacsclient.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 8346524a3e..018e81e422 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -1401,10 +1401,8 @@ local_sockname (int s, char sockname[socknamesize], int tmpdirlen, /* Put the full address name into the buffer, since the caller might need it for diagnostics. But don't overrun the buffer. */ uintmax_t uidmax = uid; - int emacsdirlen; int suffixlen = snprintf (sockname + tmpdirlen, socknamesize - tmpdirlen, - "/emacs%"PRIuMAX"%n/%s", uidmax, &emacsdirlen, - server_name); + "/emacs%"PRIuMAX"/%s", uidmax, server_name); if (! (0 <= suffixlen && suffixlen < socknamesize - tmpdirlen)) return ENAMETOOLONG; @@ -1412,7 +1410,8 @@ local_sockname (int s, char sockname[socknamesize], int tmpdirlen, this user's directory and does not let others write to it; this fends off some symlink attacks. To avoid races, keep the parent directory open while checking. */ - char *emacsdirend = sockname + tmpdirlen + emacsdirlen; + char *emacsdirend = sockname + tmpdirlen + suffixlen - + strlen(server_name) - 1; *emacsdirend = '\0'; int dir = openat (AT_FDCWD, sockname, O_PATH | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC); -- 2.32.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 22 10:24:39 2021 Received: (at 50155) by debbugs.gnu.org; 22 Aug 2021 14:24:39 +0000 Received: from localhost ([127.0.0.1]:39659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHoOo-0002th-EE for submit@debbugs.gnu.org; Sun, 22 Aug 2021 10:24:38 -0400 Received: from quimby.gnus.org ([95.216.78.240]:34304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHoOi-0002tO-Mq for 50155@debbugs.gnu.org; Sun, 22 Aug 2021 10:24:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=OJc2scxUYEHoyWl58MO8CgM9r+tqkxUzbh4kNSF3Uzw=; b=IfMgL7Oo0AT+Oc5mI+0aVrPFr7 /NuowZYJV6rH17LeiDzUXZNLV0n8OFUhNPNCL7sSH59asbfO1KQlNadocBQPBL0TanSaetW3il/ex 3x4A8H9H9K8fIohsa9C/hTrejYXMqI5BjXLX+LpOJ/BK931+7RuPfhaiTyT+05/O1XQU=; Received: from [84.212.220.105] (helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mHoOX-0007e5-8W; Sun, 22 Aug 2021 16:24:21 +0200 From: Lars Ingebrigtsen To: Omar Polo Subject: Re: bug#50155: don't use the conversion specifier %n in emacsclient References: <87zgtaxyv7.fsf@omarpolo.com> Date: Sun, 22 Aug 2021 16:24:15 +0200 In-Reply-To: <87zgtaxyv7.fsf@omarpolo.com> (Omar Polo's message of "Sat, 21 Aug 2021 23:38:04 +0200") Message-ID: <87mtp9zhf4.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Omar Polo writes: > Now, in this specific case it's used in a completely safe manner, but > avoiding it seems pretty easy. Thanks; applied to Emacs 28. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 50155 Cc: 50155@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Omar Polo writes: > Now, in this specific case it's used in a completely safe manner, but > avoiding it seems pretty easy. Thanks; applied to Emacs 28. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 22 10:24:42 2021 Received: (at control) by debbugs.gnu.org; 22 Aug 2021 14:24:42 +0000 Received: from localhost ([127.0.0.1]:39661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHoOt-0002tv-0R for submit@debbugs.gnu.org; Sun, 22 Aug 2021 10:24:42 -0400 Received: from quimby.gnus.org ([95.216.78.240]:34318) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mHoOm-0002tU-2n for control@debbugs.gnu.org; Sun, 22 Aug 2021 10:24:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=mQTiJO5hiXURyz93bUh1hM9E3hOvt10xwmzJTSW1ZjY=; b=sAa9CYUNXh5QqGYsQhkUaSsYpt NtWA28LQRKNIe3bZiFwCXJU4URuw034hBqUC20BB/xpfrvILCzmhYe3n4URtgXy8lpC0fdyNhIUls m1poeupm0LQ/SrUXtxsD7rtRhJDrbAItnTIadzvHpn2+yZxpNSQjO2nQ6YIEAaxwKfZ4=; Received: from [84.212.220.105] (helo=elva) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mHoOe-0007eE-Ad for control@debbugs.gnu.org; Sun, 22 Aug 2021 16:24:26 +0200 Date: Sun, 22 Aug 2021 16:24:23 +0200 Message-Id: <87lf4tzhew.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #50155 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 50155 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 50155 28.1 quit From unknown Sat Jun 21 10:36:53 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 20 Sep 2021 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator