[ekg2-commit] ekg2: dcc.c (HEAD) [peres]

CVS commit cvs w toxygen.net
Nie, 6 Maj 2007, 19:45:19 CEST


Module name:	ekg2
Changes by:	peres	2007-05-06 19:45:17

Modified files:
	dcc.c

Log message:
Introduce prepare_path_user() for DCC.

Index: dcc.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/gg/dcc.c,v
diff -d -u -r1.38 -r1.39
--- dcc.c	4 May 2007 10:09:40 -0000	1.38
+++ dcc.c	6 May 2007 17:45:16 -0000	1.39
@@ -231,12 +231,18 @@
 		gg_userlist_private_t *up;
 		dcc_t *d;
 		int fd;
+		const char *fn;
 
 		if (!params[1] || !params[2]) {
 			wcs_printq("not_enough_params", name);
 			return -1;
 		}
 
+		if (!(fn = prepare_path_user(params[2]))) {
+			printq("generic_error", "path too long"); /* XXX? */
+			return -1;
+		}
+
 		if (!(u = userlist_find(session, get_uid(session, params[1])))) {
 			printq("user_not_found", params[1]);
 			return -1;
@@ -258,12 +264,13 @@
 			return -1;
 		}
 		
-		if (!stat(params[2], &st) && S_ISDIR(st.st_mode)) {
+			/* XXX: if given path is a pipe, we get lovely stuck */
+		if (!stat(fn, &st) && S_ISDIR(st.st_mode)) {
 			printq("dcc_open_error", params[2], strerror(EISDIR));
 			return -1;
 		}
 		
-		if ((fd = open(params[2], O_RDONLY)) == -1) {
+		if ((fd = open(fn, O_RDONLY)) == -1) {
 			printq("dcc_open_error", params[2], strerror(errno));
 			return -1;
 		}
@@ -279,7 +286,7 @@
 				return -1;
 			}
 
-			if (gg_dcc_fill_file_info(gd, params[2]) == -1) {
+			if (gg_dcc_fill_file_info(gd, fn) == -1) {
 				printq("dcc_open_error", params[2], strerror(errno));
 				gg_free_dcc(gd);
 				return -1;
@@ -287,7 +294,7 @@
 		}
 		
 		d = dcc_add(session, u->uid, DCC_SEND, gd);
-		dcc_filename_set(d, params[2]);
+		dcc_filename_set(d, fn);
 		dcc_size_set(d, st.st_size);
 		if (gd)
 			watch_add(&gg_plugin, gd->fd, gd->check, gg_dcc_handler, gd);


Więcej informacji o liście dyskusyjnej ekg2-commit