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

CVS commit cvs w toxygen.net
Czw, 10 Maj 2007, 21:16:48 CEST


Module name:	ekg2
Changes by:	peres	2007-05-10 21:16:46

Modified files:
	dcc.c

Log message:
Better way of test-opening files in /dcc send. We should be proof of named
pipe sending and race condition caused by calling stat before opening
the file.

Index: dcc.c
===================================================================
RCS file: /home/cvs/ekg2/plugins/gg/dcc.c,v
diff -d -u -r1.39 -r1.40
--- dcc.c	6 May 2007 17:45:16 -0000	1.39
+++ dcc.c	10 May 2007 19:16:46 -0000	1.40
@@ -264,14 +264,13 @@
 			return -1;
 		}
 		
-			/* 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));
+		if ((fd = open(fn, O_RDONLY|O_NONBLOCK)) == -1) {
+			printq("io_cantopen");
 			return -1;
 		}
-		
-		if ((fd = open(fn, O_RDONLY)) == -1) {
-			printq("dcc_open_error", params[2], strerror(errno));
+
+		if (!stat(fn, &st) && !S_ISREG(st.st_mode)) {
+			printq("io_nonfile");
 			return -1;
 		}
 


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