summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Golde <nion@suckless.org>2011-01-24 16:46:25 +0100
committerNico Golde <nion@suckless.org>2011-01-24 16:46:25 +0100
commite048dac3dfcdc38d9869af04a18593046908a0a5 (patch)
tree64e4f47e9e7afcbc7a73b1a65a4ab1f285372ddd
parent566fa01e471cbbe318640150b44fa59bfe50f9a8 (diff)
downloadii-e048dac3dfcdc38d9869af04a18593046908a0a5.zip
ii-e048dac3dfcdc38d9869af04a18593046908a0a5.tar.gz
ii-e048dac3dfcdc38d9869af04a18593046908a0a5.tar.bz2
minor changes, fix fd leak due to case insensitive channel name comparison, fix treatment of raw irc commands (thanks samurai)
-rw-r--r--CHANGES7
-rw-r--r--config.mk2
-rw-r--r--ii.c22
3 files changed, 19 insertions, 12 deletions
diff --git a/CHANGES b/CHANGES
index 001cdc1..22dc841 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+1.5 (2011-01-24):
+ - fix channel name comparison in add_channel(), compare lowercase
+ to prevent leaking file descriptors in the long run => Thanks samurai!
+ - only handle commands ii explicitely understands and treat the rest
+ as raw irc (only worked for raw commands in capital lettersin the past) => Thanks samurai!
+ - minor changes
+
1.4 (2008-08-09):
- fix directory traversal on servers that support SAJOIN
NOTE: not marking as security relevant as it is only possible to
diff --git a/config.mk b/config.mk
index ac9a047..601ed05 100644
--- a/config.mk
+++ b/config.mk
@@ -12,7 +12,7 @@ DESTDIR =
INCDIR = ${PREFIX}/include
LIBDIR = ${PREFIX}/lib
-VERSION = 1.4
+VERSION = 1.5
# includes and libs
INCLUDES = -I. -I${INCDIR} -I/usr/include
diff --git a/ii.c b/ii.c
index 40021bb..c467728 100644
--- a/ii.c
+++ b/ii.c
@@ -1,8 +1,7 @@
-/*
- * (C)opyright MMV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
- * (C)opyright MMV-MMVII Nico Golde <nico at ngolde dot de>
- * See LICENSE file for license details.
- */
+/* (C)opyright MMV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
+ * (C)opyright MMV-MMXI Nico Golde <nico at ngolde dot de>
+ * See LICENSE file for license details. */
+
#include <errno.h>
#include <netdb.h>
#include <sys/types.h>
@@ -47,7 +46,7 @@ static void usage() {
fprintf(stderr, "%s",
"ii - irc it - " VERSION "\n"
"(C)opyright MMV-MMVI Anselm R. Garbe\n"
- "(C)opyright MMV-MMVII Nico Golde\n"
+ "(C)opyright MMV-MMXI Nico Golde\n"
"usage: ii [-i <irc dir>] [-s <host>] [-p <port>]\n"
" [-n <nick>] [-k <password>] [-f <fullname>]\n");
exit(EXIT_SUCCESS);
@@ -82,16 +81,16 @@ static void create_dirtree(const char *dir) {
static int get_filepath(char *filepath, size_t len, char *channel, char *file) {
if(channel) {
- if(!snprintf(filepath, len, "%s/%s", path, striplower(channel)))
+ if(!snprintf(filepath, len, "%s/%s", path, channel))
return 0;
create_dirtree(filepath);
- return snprintf(filepath, len, "%s/%s/%s", path, striplower(channel), file);
+ return snprintf(filepath, len, "%s/%s/%s", path, channel, file);
}
return snprintf(filepath, len, "%s/%s", path, file);
}
static void create_filepath(char *filepath, size_t len, char *channel, char *suffix) {
- if(!get_filepath(filepath, len, channel, suffix)) {
+ if(!get_filepath(filepath, len, striplower(channel), suffix)) {
fprintf(stderr, "%s", "ii: path to irc directory too long\n");
exit(EXIT_FAILURE);
}
@@ -105,9 +104,10 @@ static int open_channel(char *name) {
return open(infile, O_RDONLY | O_NONBLOCK, 0);
}
-static void add_channel(char *name) {
+static void add_channel(char *cname) {
Channel *c;
int fd;
+ char *name = striplower(cname);
for(c = channels; c; c = c->next)
if(!strcmp(name, c->name))
@@ -234,7 +234,7 @@ static void proc_channels_input(Channel *c, char *buf) {
return;
}
message[0] = '\0';
- switch (buf[1]) {
+ if(buf[2] == ' ' || buf[2] == '\0') switch (buf[1]) {
case 'j':
p = strchr(&buf[3], ' ');
if(p) *p = 0;