]> arthur.barton.de Git - ngircd.git/blobdiff - src/ngircd/parse.c
Allow mixed line terminations (CR+LF/CR/LF) in non-RFC-compliant mode
[ngircd.git] / src / ngircd / parse.c
index 7be52710f9a3df471fc3264d33a507109389c157..409231ae0364f751afd60982f8c3b4ce7b1f0812 100644 (file)
@@ -337,12 +337,20 @@ Validate_Command( UNUSED CONN_ID Idx, UNUSED REQUEST *Req, bool *Closed )
 static bool
 Validate_Args(CONN_ID Idx, REQUEST *Req, bool *Closed)
 {
+#ifdef STRICT_RFC
        int i;
+#endif
 
        assert( Idx >= 0 );
        assert( Req != NULL );
        *Closed = false;
 
+#ifdef STRICT_RFC
+       /* CR and LF are never allowed in command parameters.
+        * But since we do accept lines terminated only with CR or LF in
+        * "non-RFC-compliant mode" (besides the correct CR+LF combination),
+        * this check can only trigger in "strict RFC" mode; therefore we
+        * optimize it away otherwise ... */
        for (i = 0; i < Req->argc; i++) {
                if (strchr(Req->argv[i], '\r') || strchr(Req->argv[i], '\n')) {
                        Log(LOG_ERR,
@@ -354,6 +362,8 @@ Validate_Args(CONN_ID Idx, REQUEST *Req, bool *Closed)
                        return false;
                }
        }
+#endif
+
        return true;
 } /* Validate_Args */