changeset 28820:32f356585aed

Check file permissions before sending a file transfer request. Closes #1944.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Wed, 23 Dec 2009 05:50:48 +0000
parents 811c12e6d965
children edea24b65db9
files libpurple/ft.c
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/ft.c	Wed Dec 23 05:15:17 2009 +0000
+++ b/libpurple/ft.c	Wed Dec 23 05:50:48 2009 +0000
@@ -328,6 +328,23 @@
 		g_free(msg);
 		purple_xfer_request_denied(xfer);
 	}
+	else if (type == PURPLE_XFER_SEND) {
+#ifndef _WIN32
+		int mode = R_OK;
+#else
+		int mode = F_OK;
+#endif
+
+		if (g_access(filename, mode) == 0) {
+			purple_xfer_request_accepted(xfer, filename);
+		} else {
+			purple_xfer_ref(xfer);
+			purple_notify_message(
+				NULL, PURPLE_NOTIFY_MSG_ERROR, NULL,
+				_("File is not readable."), NULL,
+				(PurpleNotifyCloseCallback)purple_xfer_choose_file, xfer);
+		}
+	}
 	else {
 		purple_xfer_request_accepted(xfer, filename);
 	}