Anonymous avatar Anonymous committed 9a078e1 Merge

merged in upstream changes

Comments (0)

Files changed (4)

 daf8fc17d14014f312721c1d56ffa049392393fc ii-1.2
 987fc9d57808948b4bcf626b096c9c60226455d3 ii-1.3
 7c7c000b4f42a48676e8f98a953a981bf6b29029 1.4
+4c6892284a9ae73de3c84c164e214d31e76427a4 1.5
+4c6892284a9ae73de3c84c164e214d31e76427a4 1.5
+6f504f412a5997158b651eac8785f8331408b2e5 1.5
+6f504f412a5997158b651eac8785f8331408b2e5 1.5
+550ee110071903b9676d848d8947e96e02a8a662 1.5
+f09f802a80379d24194535c7991182ceeb9291af 1.6
+1.6 (2011-01-31):
+    - fix regression introduced for handling unknown commands
+
+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!
+    - create in FIFO on receiving a privmsg directly instead of requiring a new
+      /j command first => Thanks Evan Gates
+      this also implies that in FIFOs aren't deleted on channel leaves any longer because
+      this itself creates a channel event again which in turn would recreate the file
+    - 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
 
 INCDIR      = ${PREFIX}/include
 LIBDIR      = ${PREFIX}/lib
-VERSION     = 1.4-emg
+VERSION     = 1.6-emg
 
 # includes and libs
 INCLUDES    = -I. -I${INCDIR} -I/usr/include
-/*
- * (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>
 #define PIPE_BUF 4096
 #endif
 
+#define IS_CHANNEL(s) (((s)[0]=='#')||((s)[0]=='&')||((s)[0]=='+')||((s)[0]=='!'))
+
+#define EXIT_TIMEOUT 2
+#define PING_TIMEOUT 300
+#define SERVER_PORT 6667
 enum { TOK_NICKSRV = 0, TOK_USER, TOK_CMD, TOK_CHAN, TOK_ARG, TOK_TEXT, TOK_LAST };
 
 typedef struct Channel Channel;
 	Channel *next;
 };
 
-#define IS_CHANNEL(s) (((s)[0]=='#')||((s)[0]=='&')||((s)[0]=='+')||((s)[0]=='!'))
-
-#define EXIT_TIMEOUT 2
-#define PING_TIMEOUT 300
-#define SERVER_PORT 6667
 static int irc;
 static time_t last_response;
 static Channel *channels = NULL;
 	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);
 }
+
 static char *striplower(char *s) {
 	char *p = NULL;
 	for(p = s; p && *p; p++) {
 	char tmp[256];
 	char *p = NULL;
 	size_t len;
-
 	snprintf(tmp, sizeof(tmp),"%s",dir);
 	len = strlen(tmp);
 	if(tmp[len - 1] == '/')
 
 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);
 	}
 }
 
 static void print_out(char *channel, char *buf); // needs to be declared
-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))
 				nick, nick, host, fullname ? fullname : nick);
 	else snprintf(message, PIPE_BUF, "NICK %s\r\nUSER %s localhost %s :%s\r\n",
 				nick, nick, host, fullname ? fullname : nick);
-
 	write(irc, message, strlen(message));	/* login */
 }
 
 		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;
 		default:
 			snprintf(message, PIPE_BUF, "%s\r\n", &buf[1]);
 			break;
-	}
+		}
+	else
+		snprintf(message, PIPE_BUF, "%s\r\n", &buf[1]);
+
 	if (message[0] != '\0')
 		write(irc, message, strlen(message));
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.