* bug#37344: rcirc: nil gets interpreted as a nickname
@ 2019-09-08 18:58 Naïm Favier
2019-09-09 1:24 ` Leo Liu
0 siblings, 1 reply; 7+ messages in thread
From: Naïm Favier @ 2019-09-08 18:58 UTC (permalink / raw)
To: 37344
Severity: normal
Ever since I changed my nickname to "nil" on Freenode, I've been
getting occasional private messages from unknown users consisting of a
single empty CTCP ACTION. After a bit of investigating, it turned out
they all used rcirc. The situation was clear at that point: somewhere
in rcirc's source code, a nil value is being implicitly converted to a
string and used as the target of a PRIVMSG command.
The bug seems to be reproducible by issuing "/me" (without arguments)
inside a server buffer: the "nil" user on that server gets sent an
empty ACTION.
Suggested fix: in rcirc-send-privmsg, fail if target is nil. It might
be useful to check other places where the "%s" format is used, to
discover similar bugs.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#37344: rcirc: nil gets interpreted as a nickname
2019-09-08 18:58 bug#37344: rcirc: nil gets interpreted as a nickname Naïm Favier
@ 2019-09-09 1:24 ` Leo Liu
2019-09-09 9:56 ` Naïm Favier
2019-09-20 18:33 ` Lars Ingebrigtsen
0 siblings, 2 replies; 7+ messages in thread
From: Leo Liu @ 2019-09-09 1:24 UTC (permalink / raw)
To: Naïm Favier; +Cc: 37344
On 2019-09-08 20:58 +0200, Naïm Favier wrote:
> Severity: normal
>
> Ever since I changed my nickname to "nil" on Freenode, I've been
> getting occasional private messages from unknown users consisting of a
> single empty CTCP ACTION. After a bit of investigating, it turned out
> they all used rcirc. The situation was clear at that point: somewhere
> in rcirc's source code, a nil value is being implicitly converted to a
> string and used as the target of a PRIVMSG command.
>
> The bug seems to be reproducible by issuing "/me" (without arguments)
> inside a server buffer: the "nil" user on that server gets sent an
> empty ACTION.
>
> Suggested fix: in rcirc-send-privmsg, fail if target is nil. It might
> be useful to check other places where the "%s" format is used, to
> discover similar bugs.
Thanks. Does the following patch fix the issue?
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index de524d9e..d95db26c 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -825,6 +825,7 @@ Function is called with PROCESS, COMMAND, SENDER, ARGS and LINE.")
(process-send-string process string)))
(defun rcirc-send-privmsg (process target string)
+ (cl-check-type target string)
(rcirc-send-string process (format "PRIVMSG %s :%s" target string)))
(defun rcirc-send-ctcp (process target request &optional args)
@@ -2337,8 +2338,8 @@ With a prefix arg, prompt for new topic."
(let ((timestamp (format-time-string "%s")))
(rcirc-send-ctcp process target "PING" timestamp)))
-(defun rcirc-cmd-me (args &optional process target)
- (rcirc-send-ctcp process target "ACTION" args))
+(defun rcirc-cmd-me (args process target)
+ (when target (rcirc-send-ctcp process target "ACTION" args)))
(defun rcirc-add-or-remove (set &rest elements)
(dolist (elt elements)
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#37344: rcirc: nil gets interpreted as a nickname
2019-09-09 1:24 ` Leo Liu
@ 2019-09-09 9:56 ` Naïm Favier
2019-09-20 18:33 ` Lars Ingebrigtsen
1 sibling, 0 replies; 7+ messages in thread
From: Naïm Favier @ 2019-09-09 9:56 UTC (permalink / raw)
To: Leo Liu; +Cc: 37344
Yes, it does.
On Mon, 9 Sep 2019 at 03:24, Leo Liu <sdl.web@gmail.com> wrote:
>
> On 2019-09-08 20:58 +0200, Naïm Favier wrote:
> > Severity: normal
> >
> > Ever since I changed my nickname to "nil" on Freenode, I've been
> > getting occasional private messages from unknown users consisting of a
> > single empty CTCP ACTION. After a bit of investigating, it turned out
> > they all used rcirc. The situation was clear at that point: somewhere
> > in rcirc's source code, a nil value is being implicitly converted to a
> > string and used as the target of a PRIVMSG command.
> >
> > The bug seems to be reproducible by issuing "/me" (without arguments)
> > inside a server buffer: the "nil" user on that server gets sent an
> > empty ACTION.
> >
> > Suggested fix: in rcirc-send-privmsg, fail if target is nil. It might
> > be useful to check other places where the "%s" format is used, to
> > discover similar bugs.
>
> Thanks. Does the following patch fix the issue?
>
> diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
> index de524d9e..d95db26c 100644
> --- a/lisp/net/rcirc.el
> +++ b/lisp/net/rcirc.el
> @@ -825,6 +825,7 @@ Function is called with PROCESS, COMMAND, SENDER, ARGS and LINE.")
> (process-send-string process string)))
>
> (defun rcirc-send-privmsg (process target string)
> + (cl-check-type target string)
> (rcirc-send-string process (format "PRIVMSG %s :%s" target string)))
>
> (defun rcirc-send-ctcp (process target request &optional args)
> @@ -2337,8 +2338,8 @@ With a prefix arg, prompt for new topic."
> (let ((timestamp (format-time-string "%s")))
> (rcirc-send-ctcp process target "PING" timestamp)))
>
> -(defun rcirc-cmd-me (args &optional process target)
> - (rcirc-send-ctcp process target "ACTION" args))
> +(defun rcirc-cmd-me (args process target)
> + (when target (rcirc-send-ctcp process target "ACTION" args)))
>
> (defun rcirc-add-or-remove (set &rest elements)
> (dolist (elt elements)
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#37344: rcirc: nil gets interpreted as a nickname
2019-09-09 1:24 ` Leo Liu
2019-09-09 9:56 ` Naïm Favier
@ 2019-09-20 18:33 ` Lars Ingebrigtsen
2019-09-21 5:21 ` Leo Liu
1 sibling, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-09-20 18:33 UTC (permalink / raw)
To: Leo Liu; +Cc: Naïm Favier, 37344
Leo Liu <sdl.web@gmail.com> writes:
> Thanks. Does the following patch fix the issue?
It was confirmed that it does, so I guess you should just apply the
patch, but:
[...]
> -(defun rcirc-cmd-me (args &optional process target)
> - (rcirc-send-ctcp process target "ACTION" args))
> +(defun rcirc-cmd-me (args process target)
> + (when target (rcirc-send-ctcp process target "ACTION" args)))
Perhaps you should keep the &optional there to avoid changing the call
signature? Somebody else may have code that calls the function with
that calling convention.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#37344: rcirc: nil gets interpreted as a nickname
2019-09-20 18:33 ` Lars Ingebrigtsen
@ 2019-09-21 5:21 ` Leo Liu
2019-10-07 4:55 ` Lars Ingebrigtsen
0 siblings, 1 reply; 7+ messages in thread
From: Leo Liu @ 2019-09-21 5:21 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Naïm Favier, 37344
On 2019-09-20 20:33 +0200, Lars Ingebrigtsen wrote:
>> Thanks. Does the following patch fix the issue?
>
> It was confirmed that it does, so I guess you should just apply the
> patch, but:
Will do.
>> -(defun rcirc-cmd-me (args &optional process target)
>> - (rcirc-send-ctcp process target "ACTION" args))
>> +(defun rcirc-cmd-me (args process target)
>> + (when target (rcirc-send-ctcp process target "ACTION" args)))
>
> Perhaps you should keep the &optional there to avoid changing the call
> signature? Somebody else may have code that calls the function with
> that calling convention.
The signature is wrong from the start. Directly call them without
providing these optional (mandatory-in-disguise) arguments throws an
error, unlike commands defined by defun-rcirc-command which correctly
handle &optional arguments. I'll commit the patch as is if no
objections. Thanks for raising the issue.
Leo
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#37344: rcirc: nil gets interpreted as a nickname
2019-09-21 5:21 ` Leo Liu
@ 2019-10-07 4:55 ` Lars Ingebrigtsen
2019-10-07 11:01 ` Leo Liu
0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-07 4:55 UTC (permalink / raw)
To: Leo Liu; +Cc: Naïm Favier, 37344
Leo Liu <sdl.web@gmail.com> writes:
> The signature is wrong from the start. Directly call them without
> providing these optional (mandatory-in-disguise) arguments throws an
> error, unlike commands defined by defun-rcirc-command which correctly
> handle &optional arguments. I'll commit the patch as is if no
> objections. Thanks for raising the issue.
I have no objections; please go ahead.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#37344: rcirc: nil gets interpreted as a nickname
2019-10-07 4:55 ` Lars Ingebrigtsen
@ 2019-10-07 11:01 ` Leo Liu
0 siblings, 0 replies; 7+ messages in thread
From: Leo Liu @ 2019-10-07 11:01 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Naïm Favier, 37344-done
Version: 26.4
On 2019-10-07 06:55 +0200, Lars Ingebrigtsen wrote:
> I have no objections; please go ahead.
I have committed the change to emacs-26. Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-10-07 11:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-08 18:58 bug#37344: rcirc: nil gets interpreted as a nickname Naïm Favier
2019-09-09 1:24 ` Leo Liu
2019-09-09 9:56 ` Naïm Favier
2019-09-20 18:33 ` Lars Ingebrigtsen
2019-09-21 5:21 ` Leo Liu
2019-10-07 4:55 ` Lars Ingebrigtsen
2019-10-07 11:01 ` Leo Liu
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).