Introduction
Introduction Statistics Contact Development Disclaimer Help
harden ii a bit - ii - irc it, simple FIFO based irc client
git clone git://git.suckless.org/ii
Log
Files
Refs
README
LICENSE
---
commit 7e890e305dcdf52f6887f966bee86cc18fc41251
parent e1af846735f8a7ff7acfd9ddacb7cfd8e494a998
Author: [email protected] <unknown>
Date: Thu, 1 Feb 2007 11:21:52 +0100
harden ii a bit
Diffstat:
M ii.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/ii.c b/ii.c
@@ -231,6 +231,7 @@ static void proc_channels_input(Channel *c, char *buf) {
proc_channels_privmsg(c->name, buf);
return;
}
+ message[0] = '\0';
switch (buf[1]) {
case 'j':
p = strchr(&buf[3], ' ');
@@ -248,24 +249,28 @@ static void proc_channels_input(Channel *c, char *buf) {
}
break;
case 't':
- snprintf(message, PIPE_BUF, "TOPIC %s :%s\r\n", c->nam…
+ if(strlen(buf)>=3) snprintf(message, PIPE_BUF, "TOPIC …
break;
case 'a':
- snprintf(message, PIPE_BUF, "-!- %s is away \"%s\"", n…
- print_out(c->name, message);
- if(buf[2] == 0)
+ if(strlen(buf)>=3){
+ snprintf(message, PIPE_BUF, "-!- %s is away \"…
+ print_out(c->name, message);
+ }
+ if(buf[2] == 0 || strlen(buf)<3) /* or used to make el…
snprintf(message, PIPE_BUF, "AWAY\r\n");
else
snprintf(message, PIPE_BUF, "AWAY :%s\r\n", &b…
break;
case 'n':
- snprintf(nick, sizeof(nick),"%s", &buf[3]);
- snprintf(message, PIPE_BUF, "NICK %s\r\n", &buf[3]);
+ if(strlen(buf)>=3){
+ snprintf(nick, sizeof(nick),"%s", &buf[3]);
+ snprintf(message, PIPE_BUF, "NICK %s\r\n", &bu…
+ }
break;
case 'l':
if(c->name[0] == 0)
return;
- if(buf[2] == ' ')
+ if(buf[2] == ' ' && strlen(buf)>=3)
snprintf(message, PIPE_BUF, "PART %s :%s\r\n",…
else
snprintf(message, PIPE_BUF,
@@ -281,7 +286,8 @@ static void proc_channels_input(Channel *c, char *buf) {
snprintf(message, PIPE_BUF, "%s\r\n", &buf[1]);
break;
}
- write(irc, message, strlen(message));
+ if (message[0] != '\0')
+ write(irc, message, strlen(message));
}
static void proc_server_cmd(char *buf) {
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.