diff options
| author | Alexander Barton <alex@barton.de> | 2011-03-21 10:46:09 +0100 |
|---|---|---|
| committer | Alexander Barton <alex@barton.de> | 2011-03-21 10:46:09 +0100 |
| commit | 15775e67900d914cc174aa80e615fa24d65d115c (patch) | |
| tree | 043113e70f08c811d1340c8d5f383786d9ff2761 /src | |
| parent | 62f705f97e580fe61520793b3387081915f240ba (diff) | |
| download | ngircd-15775e67900d914cc174aa80e615fa24d65d115c.tar.gz ngircd-15775e67900d914cc174aa80e615fa24d65d115c.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ngircd/parse.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c index 8203dd0e..31f048cf 100644 --- a/src/ngircd/parse.c +++ b/src/ngircd/parse.c @@ -276,11 +276,24 @@ Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Closed ) *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 |