harden ii a bit

This commit is contained in:
nion@h4447.serverkompetenz.net 2007-02-01 11:21:52 +01:00
parent e1af846735
commit 7e890e305d

22
ii.c
View File

@ -231,6 +231,7 @@ static void proc_channels_input(Channel *c, char *buf) {
proc_channels_privmsg(c->name, buf); proc_channels_privmsg(c->name, buf);
return; return;
} }
message[0] = '\0';
switch (buf[1]) { switch (buf[1]) {
case 'j': case 'j':
p = strchr(&buf[3], ' '); p = strchr(&buf[3], ' ');
@ -248,24 +249,28 @@ static void proc_channels_input(Channel *c, char *buf) {
} }
break; break;
case 't': case 't':
snprintf(message, PIPE_BUF, "TOPIC %s :%s\r\n", c->name, &buf[3]); if(strlen(buf)>=3) snprintf(message, PIPE_BUF, "TOPIC %s :%s\r\n", c->name, &buf[3]);
break; break;
case 'a': case 'a':
snprintf(message, PIPE_BUF, "-!- %s is away \"%s\"", nick, &buf[3]); if(strlen(buf)>=3){
print_out(c->name, message); snprintf(message, PIPE_BUF, "-!- %s is away \"%s\"", nick, &buf[3]);
if(buf[2] == 0) print_out(c->name, message);
}
if(buf[2] == 0 || strlen(buf)<3) /* or used to make else part safe */
snprintf(message, PIPE_BUF, "AWAY\r\n"); snprintf(message, PIPE_BUF, "AWAY\r\n");
else else
snprintf(message, PIPE_BUF, "AWAY :%s\r\n", &buf[3]); snprintf(message, PIPE_BUF, "AWAY :%s\r\n", &buf[3]);
break; break;
case 'n': case 'n':
snprintf(nick, sizeof(nick),"%s", &buf[3]); if(strlen(buf)>=3){
snprintf(message, PIPE_BUF, "NICK %s\r\n", &buf[3]); snprintf(nick, sizeof(nick),"%s", &buf[3]);
snprintf(message, PIPE_BUF, "NICK %s\r\n", &buf[3]);
}
break; break;
case 'l': case 'l':
if(c->name[0] == 0) if(c->name[0] == 0)
return; return;
if(buf[2] == ' ') if(buf[2] == ' ' && strlen(buf)>=3)
snprintf(message, PIPE_BUF, "PART %s :%s\r\n", c->name, &buf[3]); snprintf(message, PIPE_BUF, "PART %s :%s\r\n", c->name, &buf[3]);
else else
snprintf(message, PIPE_BUF, 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]); snprintf(message, PIPE_BUF, "%s\r\n", &buf[1]);
break; break;
} }
write(irc, message, strlen(message)); if (message[0] != '\0')
write(irc, message, strlen(message));
} }
static void proc_server_cmd(char *buf) { static void proc_server_cmd(char *buf) {