commit 15775e67900d914cc174aa80e615fa24d65d115c
from: Alexander Barton <alex@barton.de>
date: Mon Mar 21 09:46:09 2011 UTC

Commands received from other servers must have prefixes

Make sure that all commands received from other servers do have
valid prefixes.

Only exceptions are PING and ERROR commands that can occure without
prefixes when generated by the remote peer itself.

commit - 62f705f97e580fe61520793b3387081915f240ba
commit + 15775e67900d914cc174aa80e615fa24d65d115c
blob - 8203dd0ecb2687617af5f911db820733d239d35d
blob + 31f048cf673408f08737647d66b8aba0bc807612
--- src/ngircd/parse.c
+++ src/ngircd/parse.c
@@ -275,12 +275,25 @@ Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Clos
 	assert( Req != NULL );
 
 	*Closed = false;
-
-	if( ! Req->prefix ) return true;
 
 	client = Conn_GetClient( Idx );
 	assert( client != NULL );
 
+	if (!Req->prefix && Client_Type(client) == CLIENT_SERVER
+	    && strcasecmp(Req->command, "ERROR") != 0
+	    && strcasecmp(Req->command, "PING") != 0)
+	{
+		Log(LOG_ERR,
+		    "Received command without prefix (connection %d, command \"%s\")!?",
+		    Idx, Req->command);
+		if (!Conn_WriteStr(Idx, "ERROR :Prefix missing"))
+			*Closed = true;
+		return false;
+	}
+
+	if (!Req->prefix)
+		return true;
+
 	/* only validate if this connection is already registered */
 	if (Client_Type(client) != CLIENT_USER
 	    && Client_Type(client) != CLIENT_SERVER