Fix corruption that occurs when connecting and reconnecting to

icbirc repeatedly. After a while, icbirc starts reusing the command
buffer from a previous connection, causing all further connections
to incorrectly parse commands.

OK maintainer (dhartmei@)
This commit is contained in:
ray 2009-06-01 07:06:12 +00:00
parent 1bc729761a
commit be50109507
4 changed files with 61 additions and 1 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.9 2007/09/15 22:36:53 merdely Exp $ # $OpenBSD: Makefile,v 1.10 2009/06/01 07:06:12 ray Exp $
COMMENT= proxy IRC client with ICB server COMMENT= proxy IRC client with ICB server
DISTNAME= icbirc-1.8 DISTNAME= icbirc-1.8
PKGNAME= ${DISTNAME}p0
CATEGORIES= net CATEGORIES= net
MASTER_SITES= http://www.benzedrine.cx/ MASTER_SITES= http://www.benzedrine.cx/

View File

@ -0,0 +1,37 @@
$OpenBSD: patch-icb_c,v 1.1 2009/06/01 07:06:12 ray Exp $
--- icb.c.orig Thu Nov 18 13:14:06 2004
+++ icb.c Sat May 30 20:29:23 2009
@@ -60,6 +60,7 @@ static char icurgroup[256];
static char igroup[256];
static char inick[256];
static char ihostmask[256];
+static unsigned off;
/*
* A single ICB packet consists of a length byte, a command byte and
@@ -124,10 +125,24 @@ scan(const char **s, char *d, size_t siz, const char *
}
void
+icb_init(void)
+{
+ memset(icb_protolevel, 0, sizeof(icb_protolevel));
+ memset(icb_hostid, 0, sizeof(icb_hostid));
+ memset(icb_serverid, 0, sizeof(icb_serverid));
+ memset(icb_moderator, 0, sizeof(icb_moderator));
+ imode = imode_none;
+ memset(icurgroup, 0, sizeof(icurgroup));
+ memset(igroup, 0, sizeof(igroup));
+ memset(inick, 0, sizeof(inick));
+ memset(ihostmask, 0, sizeof(ihostmask));
+ off = 0;
+}
+
+void
icb_recv(const char *buf, unsigned len, int fd, int server_fd)
{
static unsigned char cmd[256];
- static unsigned off = 0;
while (len > 0) {
if (off == 0) {

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-icb_h,v 1.1 2009/06/01 07:06:12 ray Exp $
--- icb.h.orig Thu Nov 18 13:14:06 2004
+++ icb.h Sat May 30 20:29:23 2009
@@ -3,6 +3,7 @@
#ifndef _ICB_H_
#define _ICB_H_
+void icb_init(void);
void icb_recv(const char *, unsigned, int, int);
void icb_send_login(int, const char *, const char *, const char *);
void icb_send_openmsg(int, const char *);

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-icbirc_c,v 1.1 2009/06/01 07:06:12 ray Exp $
--- icbirc.c.orig Thu Nov 18 13:14:06 2004
+++ icbirc.c Sat May 30 20:29:23 2009
@@ -258,6 +258,7 @@ handle_client(int client_fd)
irc_send_notice(client_fd, "Connected");
terminate_client = 0;
+ icb_init();
while (!terminate_client) {
fd_set readfds;
struct timeval tv;