Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Branch tags: u2_10_12_branch
Commit time: 2007-03-27 03:37:49 UTC
Modified files:
Tag: u2_10_12_branch
tests/ircd.conf ircd/s_auth.c ChangeLog
Added files:
Tag: u2_10_12_branch
tests/iauth-test tests/bug-1685648.cmd
Log message:
Check for missing parameters to iauth messages (SF bug#1685648).
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.710.2.169 ircu2.10/ChangeLog:1.710.2.170
--- ircu2.10/ChangeLog:1.710.2.169 Mon Mar 26 19:54:44 2007
+++ ircu2.10/ChangeLog Mon Mar 26 20:37:39 2007
@@ -1,5 +1,16 @@
2007-03-26 Michael Poole <[EMAIL PROTECTED]>
+ * ircd/s_auth.c (iauth_parse): Check for missing arguments when
+ parsing the iauth message.
+
+ * tests/bug-1685648.cmd: New file to test this.
+
+ * tests/iauth-test: New file to exercise the code path.
+
+ * tests/ircd.conf: Use the iauth-test helper program.
+
+2007-03-26 Michael Poole <[EMAIL PROTECTED]>
+
* ircd/m_silence.c (forward_silences): Do not try twice to process
silences that were both added and deleted.
Index: ircu2.10/ircd/s_auth.c
diff -u ircu2.10/ircd/s_auth.c:1.37.2.21 ircu2.10/ircd/s_auth.c:1.37.2.22
--- ircu2.10/ircd/s_auth.c:1.37.2.21 Mon Jan 15 17:21:37 2007
+++ ircu2.10/ircd/s_auth.c Mon Mar 26 20:37:39 2007
@@ -31,7 +31,7 @@
*/
/** @file
* @brief Implementation of DNS and ident lookups.
- * @version $Id: s_auth.c,v 1.37.2.21 2007/01/16 01:21:37 entrope Exp $
+ * @version $Id: s_auth.c,v 1.37.2.22 2007/03/27 03:37:39 entrope Exp $
*/
#include "config.h"
@@ -1990,7 +1990,9 @@
} else {
/* Try to find the client associated with the request. */
id = strtol(params[0], NULL, 10);
- if (id < 0 || id > HighestFd || !(cli = LocalClientArray[id]))
+ if (parc < 3)
+ sendto_iauth(NULL, "E Missing :Need <id> <ip> <port>");
+ else if (id < 0 || id > HighestFd || !(cli = LocalClientArray[id]))
/* Client no longer exists (or never existed). */
sendto_iauth(NULL, "E Gone :[%s %s %s]", params[0], params[1],
params[2]);
Index: ircu2.10/tests/bug-1685648.cmd
diff -u /dev/null ircu2.10/tests/bug-1685648.cmd:1.1.2.1
--- /dev/null Mon Mar 26 20:37:49 2007
+++ ircu2.10/tests/bug-1685648.cmd Mon Mar 26 20:37:38 2007
@@ -0,0 +1,9 @@
+define srv1 localhost:7601
+define srv1-name irc.example.net
+define cl1-nick Bug1685648
+define channel #random-channel
+
+connect cl1 %cl1-nick% buguser %srv1% :Some buggy user
+:cl1 join %channel%
+:cl1 expect %srv1-name% 366 %channel%
+:cl1 quit done
Index: ircu2.10/tests/iauth-test
diff -u /dev/null ircu2.10/tests/iauth-test:1.1.2.1
--- /dev/null Mon Mar 26 20:37:49 2007
+++ ircu2.10/tests/iauth-test Mon Mar 26 20:37:38 2007
@@ -0,0 +1,66 @@
+#! /usr/bin/perl
+# iauth-test: test script for IRC authorization (iauth) protocol
+# Copyright 2006-2007 Michael Poole
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+
+require 5.008; # We assume deferred signal handlers, new in 5.008.
+use strict;
+use warnings;
+use vars qw(%pending);
+
+use FileHandle; # for autoflush method on file handles
+
+# This script is an iauth helper script to help check for bugs in
+# ircu's IAuth handling.
+
+sub dolog ($) {
+ print LOG "$_[0]\n";
+}
+
+sub reply ($;$$) {
+ my ($msg, $client, $extra) = @_;
+
+ if (not defined $msg) {
+ # Accept this for easier handling of client reply messages.
+ return;
+ } elsif (ref $msg eq '') {
+ $msg =~ s/^(.) ?/$1 $client->{id} $client->{ip} $client->{port} / if
$client;
+ dolog "< $msg";
+ print "$msg\n";
+ } elsif (ref $msg eq 'ARRAY') {
+ grep { reply($_, $client, $extra); } @$msg;
+ } elsif (ref $msg eq 'CODE') {
+ &$msg($client, $extra);
+ } else {
+ die "Unknown reply message type.";
+ }
+}
+
+open LOG, ">> iauth.log";
+autoflush LOG 1;
+autoflush STDOUT 1;
+autoflush STDERR 1;
+dolog "IAuth starting at " . scalar(localtime(time));
+reply("O ARU");
+
+while (<>) {
+ # Chomp newline and log incoming message.
+ s/\r?\n?\r?$//;
+ dolog "> $_";
+
+ # If there's an ID at the start of the line, parse it out.
+ my $client = $pending{my $id = $1} if s/^(\d+) //;
+
+ # Figure out how to handle the command.
+ if (/^C (\S+) (\S+) (.+)$/) {
+ $pending{$id} = { id => $id, ip => $1, port => $2 };
+ } elsif (/^([DT])/ and $client) {
+ delete $pending{$id};
+ } elsif (/^n (.+)$/ and $client) {
+ reply("C $client->{id} :Do not choke on missing parameters.") if $1 eq
'Bug1685648';
+ reply("D", $client);
+ }
+}
Index: ircu2.10/tests/ircd.conf
diff -u ircu2.10/tests/ircd.conf:1.1.2.2 ircu2.10/tests/ircd.conf:1.1.2.3
--- ircu2.10/tests/ircd.conf:1.1.2.2 Mon Mar 5 18:22:59 2007
+++ ircu2.10/tests/ircd.conf Mon Mar 26 20:37:38 2007
@@ -33,6 +33,7 @@
Operator { local = no; class = "Local"; host = "[EMAIL PROTECTED]"; password =
"$PLAIN$oper"; name = "oper"; };
Port { server = yes; port = 7600; };
Port { port = 7601; };
+IAuth { program = "../tests/iauth-test"; };
Features {
"HUB" = "TRUE";
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches