about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2011-07-19 16:00:55 +0200
committerAlexander Barton <alex@barton.de>2011-07-19 16:07:34 +0200
commit6cbe13085d3c8767a70d2394840a0a03ac6f290a (patch)
tree6a2db94f3e28e2e18cd34086838849e93523afb0 /src
parentb7780e3f2acb989fab7d98cb79d5f5dff65accbc (diff)
downloadngircd-6cbe13085d3c8767a70d2394840a0a03ac6f290a.tar.gz
ngircd-6cbe13085d3c8767a70d2394840a0a03ac6f290a.zip
Spoofed prefixes: close connection on non-server links only
On server-links, spoofed prefixes can happen because of the asynchronous
nature of the IRC protocol. So don't break server-links, only log a message
and ignore the command.

This fixes bug 113, see:
<https://arthur.barton.de/bugzilla/show_bug.cgi?id=113>
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/parse.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c
index 72e34309..be3c864d 100644
--- a/src/ngircd/parse.c
+++ b/src/ngircd/parse.c
@@ -325,13 +325,21 @@ Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Closed )
 	/* check if the client named in the prefix is expected
 	 * to come from that direction */
 	if (Client_NextHop(c) != client) {
-		Log(LOG_ERR,
-		    "Spoofed prefix \"%s\" from \"%s\" (connection %d, command \"%s\")!",
-		    Req->prefix, Client_Mask(Conn_GetClient(Idx)), Idx,
-		    Req->command);
-		Conn_Close(Idx, NULL, "Spoofed prefix", true);
-		*Closed = true;
+		if (Client_Type(c) != CLIENT_SERVER) {
+			Log(LOG_ERR,
+			    "Spoofed prefix \"%s\" from \"%s\" (connection %d, command \"%s\")!",
+			    Req->prefix, Client_Mask(Conn_GetClient(Idx)), Idx,
+			    Req->command);
+			Conn_Close(Idx, NULL, "Spoofed prefix", true);
+			*Closed = true;
+		} else {
+			Log(LOG_INFO,
+			    "Ignoring spoofed prefix \"%s\" from \"%s\" (connection %d, command \"%s\").",
+			    Req->prefix, Client_Mask(Conn_GetClient(Idx)), Idx,
+			    Req->command);
+		}
 		return false;
+
 	}
 
 	return true;