unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#62421: 30.0.50; ERC >5.5: Split overlong outgoing messages in erc-sasl
@ 2023-03-24 15:10 J.P.
  0 siblings, 0 replies; only message in thread
From: J.P. @ 2023-03-24 15:10 UTC (permalink / raw)
  To: 62421; +Cc: emacs-erc

[-- Attachment #1: Type: text/plain, Size: 3605 bytes --]

Tags: patch

ERC should probably account for corner cases in which the terminal
argument of a C2S AUTHENTICATE message exceeds 400 bytes. See also
https://github.com/ircv3/ircv3-specifications/pull/521.


In GNU Emacs 30.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version
 3.24.35, cairo version 1.17.6) of 2023-03-24 built on localhost
Repository revision: 103ebbf92f375cc6f44a2b49c85fbe3a6b1704d4
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12014000
System Description: Fedora Linux 36 (Workstation Edition)

Configured using:
 'configure --enable-check-lisp-object-type --enable-checking=yes,glyphs
 'CFLAGS=-O0 -g3'
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec epa epg rfc6068 epg-config gnus-util
text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils erc-goodies erc derived iso8601 time-date
thingatpt pp format-spec erc-backend erc-networks easy-mmode erc-common
inline erc-compat pcase rx url-parse auth-source cl-seq eieio eieio-core
cl-macs password-cache json map byte-opt gv bytecomp byte-compile
url-vars subr-x cl-loaddefs cl-lib erc-loaddefs rmc iso-transl tooltip
cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process
emacs)

Memory information:
((conses 16 118973 8783)
 (symbols 48 9970 0)
 (strings 32 25116 1730)
 (string-bytes 1 826188)
 (vectors 16 13837)
 (vector-slots 8 199741 7508)
 (floats 8 24 41)
 (intervals 56 235 0)
 (buffers 976 11))


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-5.6-Split-overlong-outgoing-messages-in-erc-sasl.patch --]
[-- Type: text/x-patch, Size: 12125 bytes --]

From 30ebce183280d820e89b78b857c35169a7ba4c70 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Fri, 24 Mar 2023 06:16:56 -0700
Subject: [PATCH] [5.6] Split overlong outgoing messages in erc-sasl

* lisp/erc/erc-sasl.el: (erc-server-AUTHENTICATE): Account for
client messages exceeding 400 bytes.
* test/lisp/erc/erc-scenarios-sasl.el
(erc-scenarios-sasl--plain-overlong-split,
erc-scenarios-sasl--plain-overlong-aligned): Add tests.
* test/lisp/erc/resources/sasl/plain-overlong-aligned.eld: New file.
* test/lisp/erc/resources/sasl/plain-overlong-split.eld: New file.
---
 lisp/erc/erc-sasl.el                          |  9 ++-
 test/lisp/erc/erc-scenarios-sasl.el           | 64 +++++++++++++++++++
 .../resources/sasl/plain-overlong-aligned.eld | 39 +++++++++++
 .../resources/sasl/plain-overlong-split.eld   | 39 +++++++++++
 4 files changed, 148 insertions(+), 3 deletions(-)
 create mode 100644 test/lisp/erc/resources/sasl/plain-overlong-aligned.eld
 create mode 100644 test/lisp/erc/resources/sasl/plain-overlong-split.eld

diff --git a/lisp/erc/erc-sasl.el b/lisp/erc/erc-sasl.el
index 9265691c2d7..bfe17285a68 100644
--- a/lisp/erc/erc-sasl.el
+++ b/lisp/erc/erc-sasl.el
@@ -369,9 +369,12 @@ sasl
             data (sasl-step-data step))
       (when (string= data "")
         (setq data nil))
-      (when data
-        (setq data (erc--unfun (base64-encode-string data t))))
-      (erc-server-send (concat "AUTHENTICATE " (or data "+"))))))
+      (setq data (if data (erc--unfun (base64-encode-string data t)) "+"))
+      (while (not (string-empty-p data))
+        (let ((end (min 400 (length data))))
+          ;; For now, assume this is unlikely to block
+          (erc-server-send (concat "AUTHENTICATE " (substring data 0 end)))
+          (setq data (concat (substring data end) (and (= end 400) "+"))))))))
 
 (defun erc-sasl--destroy (proc)
   (run-hook-with-args 'erc-quit-hook proc)
diff --git a/test/lisp/erc/erc-scenarios-sasl.el b/test/lisp/erc/erc-scenarios-sasl.el
index 3878237c7d2..ab652d72dd2 100644
--- a/test/lisp/erc/erc-scenarios-sasl.el
+++ b/test/lisp/erc/erc-scenarios-sasl.el
@@ -51,6 +51,70 @@ erc-scenarios-sasl--plain
         ;; Regression "\0\0\0\0 ..." caused by (fillarray passphrase 0)
         (should (string= erc-sasl-password "password123"))))))
 
+;; The user's unreasonably long password is apportioned into chunks on
+;; the way out the door.
+
+(ert-deftest erc-scenarios-sasl--plain-overlong-split ()
+  :tags '(:expensive-test)
+  (erc-scenarios-common-with-cleanup
+      ((erc-scenarios-common-dialog "sasl")
+       (erc-server-flood-penalty 0.1)
+       (dumb-server (erc-d-run "localhost" t 'plain-overlong-split))
+       (port (process-contact dumb-server :service))
+       (erc-modules (cons 'sasl erc-modules))
+       (erc-sasl-password
+        (concat
+         "Est ut beatae omnis ipsam. "
+         "Quis fugiat deleniti totam qui. "
+         "Ipsum quam a dolorum tempora velit laborum odit. "
+         "Et saepe voluptate sed cumque vel. "
+         "Voluptas sint ab pariatur libero veritatis corrupti. "
+         "Vero iure omnis ullam. "
+         "Vero beatae dolores facere fugiat ipsam. "
+         "Ea est pariatur minima nobis sunt aut ut. "
+         "Dolores ut laudantium maiores temporibus voluptates. "
+         "Reiciendis impedit omnis et unde delectus quas ab. "
+         "Quae eligendi necessitatibus doloribus "
+         "molestias tempora magnam assumenda."))
+       (expect (erc-d-t-make-expecter)))
+
+    (ert-info ("Connect")
+      (with-current-buffer (erc :server "127.0.0.1"
+                                :port port
+                                :nick "emersion"
+                                :user "emersion"
+                                :full-name "emersion")
+        (funcall expect 10 "This server is in debug mode")
+        (erc-cmd-QUIT "")))))
+
+(ert-deftest erc-scenarios-sasl--plain-overlong-aligned ()
+  :tags '(:expensive-test)
+  (erc-scenarios-common-with-cleanup
+      ((erc-scenarios-common-dialog "sasl")
+       (erc-server-flood-penalty 0.1)
+       (dumb-server (erc-d-run "localhost" t 'plain-overlong-aligned))
+       (port (process-contact dumb-server :service))
+       (erc-modules (cons 'sasl erc-modules))
+       (erc-sasl-password
+        (concat
+         "Est ut beatae omnis ipsam. "
+         "Quis fugiat deleniti totam qui. "
+         "Ipsum quam a dolorum tempora velit laborum odit. "
+         "Et saepe voluptate sed cumque vel. "
+         "Voluptas sint ab pariatur libero veritatis corrupti. "
+         "Vero iure omnis ullam. Vero beatae dolores facere fugiat ipsam. "
+         "Ea est pariatur minima nobis"))
+       (expect (erc-d-t-make-expecter)))
+
+    (ert-info ("Connect")
+      (with-current-buffer (erc :server "127.0.0.1"
+                                :port port
+                                :nick "emersion"
+                                :user "emersion"
+                                :full-name "emersion")
+        (funcall expect 10 "This server is in debug mode")
+        (erc-cmd-QUIT "")))))
+
 (ert-deftest erc-scenarios-sasl--external ()
   :tags '(:expensive-test)
   (erc-scenarios-common-with-cleanup
diff --git a/test/lisp/erc/resources/sasl/plain-overlong-aligned.eld b/test/lisp/erc/resources/sasl/plain-overlong-aligned.eld
new file mode 100644
index 00000000000..6ed8981be0f
--- /dev/null
+++ b/test/lisp/erc/resources/sasl/plain-overlong-aligned.eld
@@ -0,0 +1,39 @@
+;; -*- mode: lisp-data; -*-
+((cap-req 10 "CAP REQ :sasl"))
+((nick 10 "NICK emersion"))
+((user 10 "USER emersion 0 * :emersion")
+ (0.0 ":irc.example.org NOTICE * :*** Looking up your hostname...")
+ (0.0 ":irc.example.org NOTICE * :*** Found your hostname")
+ (0.0 ":irc.example.org CAP * ACK :sasl"))
+
+((authenticate-plain 10 "AUTHENTICATE PLAIN")
+ (0.0 ":irc.example.org AUTHENTICATE +"))
+((authenticate-gimme-1 10 "AUTHENTICATE AGVtZXJzaW9uAEVzdCB1dCBiZWF0YWUgb21uaXMgaXBzYW0uIFF1aXMgZnVnaWF0IGRlbGVuaXRpIHRvdGFtIHF1aS4gSXBzdW0gcXVhbSBhIGRvbG9ydW0gdGVtcG9yYSB2ZWxpdCBsYWJvcnVtIG9kaXQuIEV0IHNhZXBlIHZvbHVwdGF0ZSBzZWQgY3VtcXVlIHZlbC4gVm9sdXB0YXMgc2ludCBhYiBwYXJpYXR1ciBsaWJlcm8gdmVyaXRhdGlzIGNvcnJ1cHRpLiBWZXJvIGl1cmUgb21uaXMgdWxsYW0uIFZlcm8gYmVhdGFlIGRvbG9yZXMgZmFjZXJlIGZ1Z2lhdCBpcHNhbS4gRWEgZXN0IHBhcmlhdHVyIG1pbmltYSBub2Jpcw=="))
+((authenticate-gimme-2 10 "AUTHENTICATE +")
+ (0.0 ":irc.example.org 900 * * emersion :You are now logged in as emersion")
+ (0.0 ":irc.example.org 903 * :Authentication successful"))
+
+((cap-end 10 "CAP END")
+ (0.0 ":irc.example.org 001 emersion :Welcome to the ExampleOrg IRC Network emersion")
+ (0.0 ":irc.example.org 002 emersion :Your host is irc.example.org, running version oragono-2.6.1")
+ (0.0 ":irc.example.org 003 emersion :This server was created Sat, 17 Jul 2021 09:06:42 UTC")
+ (0.0 ":irc.example.org 004 emersion irc.example.org oragono-2.6.1 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv")
+ (0.0 ":irc.example.org 005 emersion AWAYLEN=200 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server")
+ (0.0 ":irc.example.org 005 emersion MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=ExampleOrg NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY :are supported by this server")
+ (0.0 ":irc.example.org 005 emersion draft/CHATHISTORY=100 :are supported by this server")
+ (0.0 ":irc.example.org 251 emersion :There are 1 users and 0 invisible on 1 server(s)")
+ (0.0 ":irc.example.org 252 emersion 0 :IRC Operators online")
+ (0.0 ":irc.example.org 253 emersion 0 :unregistered connections")
+ (0.0 ":irc.example.org 254 emersion 0 :channels formed")
+ (0.0 ":irc.example.org 255 emersion :I have 1 clients and 0 servers")
+ (0.0 ":irc.example.org 265 emersion 1 1 :Current local users 1, max 1")
+ (0.0 ":irc.example.org 266 emersion 1 1 :Current global users 1, max 1")
+ (0.0 ":irc.example.org 422 emersion :MOTD File is missing"))
+
+((mode-user 10 "MODE emersion +i")
+ (0.0 ":irc.example.org 221 emersion +Zi")
+ (0.0 ":irc.example.org NOTICE emersion :This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect."))
+
+((quit 5 "QUIT :\2ERC\2")
+ (0 ":emersion!~u@yuvqisyu7m7qs.irc QUIT :Quit"))
+((drop 1 DROP))
diff --git a/test/lisp/erc/resources/sasl/plain-overlong-split.eld b/test/lisp/erc/resources/sasl/plain-overlong-split.eld
new file mode 100644
index 00000000000..3e6870790f3
--- /dev/null
+++ b/test/lisp/erc/resources/sasl/plain-overlong-split.eld
@@ -0,0 +1,39 @@
+;; -*- mode: lisp-data; -*-
+((cap-req 10 "CAP REQ :sasl"))
+((nick 10 "NICK emersion"))
+((user 10 "USER emersion 0 * :emersion")
+ (0.0 ":irc.example.org NOTICE * :*** Looking up your hostname...")
+ (0.0 ":irc.example.org NOTICE * :*** Found your hostname")
+ (0.0 ":irc.example.org CAP * ACK :sasl"))
+
+((authenticate-plain 10 "AUTHENTICATE PLAIN")
+ (0.0 ":irc.example.org AUTHENTICATE +"))
+((authenticate-gimme-1 10 "AUTHENTICATE AGVtZXJzaW9uAEVzdCB1dCBiZWF0YWUgb21uaXMgaXBzYW0uIFF1aXMgZnVnaWF0IGRlbGVuaXRpIHRvdGFtIHF1aS4gSXBzdW0gcXVhbSBhIGRvbG9ydW0gdGVtcG9yYSB2ZWxpdCBsYWJvcnVtIG9kaXQuIEV0IHNhZXBlIHZvbHVwdGF0ZSBzZWQgY3VtcXVlIHZlbC4gVm9sdXB0YXMgc2ludCBhYiBwYXJpYXR1ciBsaWJlcm8gdmVyaXRhdGlzIGNvcnJ1cHRpLiBWZXJvIGl1cmUgb21uaXMgdWxsYW0uIFZlcm8gYmVhdGFlIGRvbG9yZXMgZmFjZXJlIGZ1Z2lhdCBpcHNhbS4gRWEgZXN0IHBhcmlhdHVyIG1pbmltYSBub2JpcyBz"))
+((authenticate-gimme-2 10 "AUTHENTICATE dW50IGF1dCB1dC4gRG9sb3JlcyB1dCBsYXVkYW50aXVtIG1haW9yZXMgdGVtcG9yaWJ1cyB2b2x1cHRhdGVzLiBSZWljaWVuZGlzIGltcGVkaXQgb21uaXMgZXQgdW5kZSBkZWxlY3R1cyBxdWFzIGFiLiBRdWFlIGVsaWdlbmRpIG5lY2Vzc2l0YXRpYnVzIGRvbG9yaWJ1cyBtb2xlc3RpYXMgdGVtcG9yYSBtYWduYW0gYXNzdW1lbmRhLg==")
+ (0.0 ":irc.example.org 900 * * emersion :You are now logged in as emersion")
+ (0.0 ":irc.example.org 903 * :Authentication successful"))
+
+((cap-end 10 "CAP END")
+ (0.0 ":irc.example.org 001 emersion :Welcome to the ExampleOrg IRC Network emersion")
+ (0.0 ":irc.example.org 002 emersion :Your host is irc.example.org, running version oragono-2.6.1")
+ (0.0 ":irc.example.org 003 emersion :This server was created Sat, 17 Jul 2021 09:06:42 UTC")
+ (0.0 ":irc.example.org 004 emersion irc.example.org oragono-2.6.1 BERTZios CEIMRUabefhiklmnoqstuv Iabefhkloqv")
+ (0.0 ":irc.example.org 005 emersion AWAYLEN=200 BOT=B CASEMAPPING=ascii CHANLIMIT=#:100 CHANMODES=Ibe,k,fl,CEMRUimnstu CHANNELLEN=64 CHANTYPES=# ELIST=U EXCEPTS EXTBAN=,m FORWARD=f INVEX KICKLEN=390 :are supported by this server")
+ (0.0 ":irc.example.org 005 emersion MAXLIST=beI:60 MAXTARGETS=4 MODES MONITOR=100 NETWORK=ExampleOrg NICKLEN=32 PREFIX=(qaohv)~&@%+ STATUSMSG=~&@%+ TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,USERHOST:10,PRIVMSG:4,TAGMSG:4,NOTICE:4,MONITOR:100 TOPICLEN=390 UTF8MAPPING=rfc8265 UTF8ONLY :are supported by this server")
+ (0.0 ":irc.example.org 005 emersion draft/CHATHISTORY=100 :are supported by this server")
+ (0.0 ":irc.example.org 251 emersion :There are 1 users and 0 invisible on 1 server(s)")
+ (0.0 ":irc.example.org 252 emersion 0 :IRC Operators online")
+ (0.0 ":irc.example.org 253 emersion 0 :unregistered connections")
+ (0.0 ":irc.example.org 254 emersion 0 :channels formed")
+ (0.0 ":irc.example.org 255 emersion :I have 1 clients and 0 servers")
+ (0.0 ":irc.example.org 265 emersion 1 1 :Current local users 1, max 1")
+ (0.0 ":irc.example.org 266 emersion 1 1 :Current global users 1, max 1")
+ (0.0 ":irc.example.org 422 emersion :MOTD File is missing"))
+
+((mode-user 10 "MODE emersion +i")
+ (0.0 ":irc.example.org 221 emersion +Zi")
+ (0.0 ":irc.example.org NOTICE emersion :This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect."))
+
+((quit 5 "QUIT :\2ERC\2")
+ (0 ":emersion!~u@yuvqisyu7m7qs.irc QUIT :Quit"))
+((drop 1 DROP))
-- 
2.39.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-24 15:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 15:10 bug#62421: 30.0.50; ERC >5.5: Split overlong outgoing messages in erc-sasl J.P.

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).