Subject: bug#33145: 27.0.50; rcirc race receives duplicate messages

From: "Basil L. Contovounesios" <[email-masked]>
Date: Thu, 25 Oct 2018 04:07:33 +0100

>From b5af2a63844fcdceab4520dae9c298c240a07df2 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <[email-masked]>
Date: Thu, 25 Oct 2018 03:35:57 +0100
Subject: [PATCH] Avoid race in rcirc process filter (bug#33145)

* lisp/net/rcirc.el (rcirc-filter): Clear rcirc-process-output
before processing its constituent lines.  Otherwise, if rcirc-filter
runs again before the last rcirc-process-server-response is
finished, the contents of rcirc-process-output could be duplicated.
---
 lisp/net/rcirc.el | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index fe9c71a21c..893ff5829b 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -751,12 +751,12 @@ rcirc-filter
   (with-rcirc-process-buffer process
     (setq rcirc-last-server-message-time (current-time))
     (setq rcirc-process-output (concat rcirc-process-output output))
-    (when (= (aref rcirc-process-output
-                   (1- (length rcirc-process-output))) ?\n)
-      (mapc (lambda (line)
-              (rcirc-process-server-response process line))
-            (split-string rcirc-process-output "[\n\r]" t))
-      (setq rcirc-process-output nil))))
+    (when (= ?\n (aref rcirc-process-output
+                       (1- (length rcirc-process-output))))
+      (let ((lines (split-string rcirc-process-output "[\n\r]" t)))
+        (setq rcirc-process-output nil)
+        (dolist (line lines)
+          (rcirc-process-server-response process line))))))
 
 (defun rcirc-reschedule-timeout (process)
   (with-rcirc-process-buffer process
-- 
2.19.1

"Basil L. Contovounesios" <[email-masked]> writes:

> Patch addressing this to follow.

I attach said patch.

Thanks,

-- 
Basil