]> arthur.barton.de Git - ngircd.git/commitdiff
IRC_SERVER: Make sure that the client sent a prefix
authorAlexander Barton <alex@barton.de>
Mon, 25 May 2020 21:43:29 +0000 (23:43 +0200)
committerAlexander Barton <alex@barton.de>
Mon, 25 May 2020 21:51:00 +0000 (23:51 +0200)
The SERVER command is only valid with a prefix when received from other
servers, so make sure that there is one and disconnect the peer if not
(instead of crashing ...).

This obsoletes PR #275.

Thanks Hilko Bengen (hillu) for finding & reporting this as well for the
patch & pull request! But I think this is the "more correct" fix.

src/ngircd/irc-server.c

index 317a3e1a1bf99c8379cb20e83419684024c262af..10f1ef697485886f891dba33eb6a1f9780d90a6c 100644 (file)
@@ -186,6 +186,15 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
                if (!Client_CheckID(Client, Req->argv[0]))
                        return DISCONNECTED;
 
+               if (!Req->prefix) {
+                       /* We definitely need a prefix here! */
+                       Log(LOG_ALERT, "Got SERVER command without prefix! (on connection %d)",
+                           Client_Conn(Client));
+                       Conn_Close(Client_Conn(Client), NULL,
+                                  "SERVER command without prefix", true);
+                       return DISCONNECTED;
+               }
+
                from = Client_Search( Req->prefix );
                if (! from) {
                        /* Uh, Server, that introduced the new server is unknown?! */