[Pkg-wmaker-commits] [wmbiff] 04/05: Sam Izzo's patch

Doug Torrance dtorrance-guest at moszumanska.debian.org
Thu Aug 20 03:05:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to tag wmbiff_0_4_20
in repository wmbiff.

commit 2d763310e1488c9264f5b3a4bcd3ea319d595d93
Author: bluehal <bluehal>
Date:   Thu Jan 1 07:47:50 2004 +0000

    Sam Izzo's patch
---
 AUTHORS                |   1 +
 NEWS                   |   6 ++-
 wmbiff/Client.h        |  34 +++++++++------
 wmbiff/Imap4Client.c   |   9 +++-
 wmbiff/ShellClient.c   |   7 +++
 wmbiff/maildirClient.c |  15 ++++---
 wmbiff/mboxClient.c    |  14 ++++--
 wmbiff/passwordMgr.c   |  20 ++++++---
 wmbiff/wmbiff.c        | 113 +++++++++++++++++++++++++++++++++++++++++--------
 9 files changed, 170 insertions(+), 49 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 35905fd..da65634 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -38,4 +38,5 @@
    Jun-ichiro itojun Hagino (itojun at iijlab.net)
    Peter McAlpine (pmcalpin at uoguelph.ca)
    Paolo Gianrossi (paolino at yersinia.org)
+   Sam Izzo (izzo at humbug.net)
 
diff --git a/NEWS b/NEWS
index b6b8b83..00ed8c6 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,10 @@
 Release Notes
 ~~~~~~~~~~~~~
-Release 0.4.20 - 
+Release 0.4.20 - January 1, 2004
   * Add --disable-crypto for source-based distributions 
     while libgcrypt is unstable.
+  * Sam Izzo's patch for changing the mouse click action
+    depending on whether a box has new mail.
 
 Release 0.4.19 - November 8, 2003
   * Fix test_tlscomm with the right signature for read()
@@ -458,4 +460,4 @@ Release 0.1 - Wed, 17 Nov 1999 00:00:00 +0000
   * Initial release by Gennady Belyakov <gb at ccat.elect.ru>.
 
 
-$Id: NEWS,v 1.54 2003/12/30 19:44:02 bluehal Exp $
+$Id: NEWS,v 1.55 2004/01/01 07:47:50 bluehal Exp $
diff --git a/wmbiff/Client.h b/wmbiff/Client.h
index 6b6cd8e..7d869d3 100644
--- a/wmbiff/Client.h
+++ b/wmbiff/Client.h
@@ -1,11 +1,11 @@
-/* $Id: Client.h,v 1.37 2003/11/08 23:46:02 bluehal Exp $ */
+/* $Id: Client.h,v 1.38 2004/01/01 07:47:50 bluehal Exp $ */
 /* Author : Scott Holden ( scotth at thezone.net )
    Modified : Yong-iL Joh ( tolkien at mizi.com )
    Modified : Jorge Garc�a ( Jorge.Garcia at uv.es )
  *
  * Email Checker Pop3/Imap4/Licq/Gicu/mbox/maildir/finger
  *
- * Last Updated : $Date: 2003/11/08 23:46:02 $
+ * Last Updated : $Date: 2004/01/01 07:47:50 $
  *
  */
 
@@ -28,15 +28,25 @@
 typedef unsigned int off_t;
 #endif
 
+#define BUF_BIG 256
+#define BUF_SMALL 32
+#define BUF_SIZE 1024
+
 struct msglst;
 typedef struct _mbox_t *Pop3;
 typedef struct _mbox_t {
-	char label[32];				/* Printed at left; max 5 chars */
-	char path[256];				/* Path to mailbox */
-	char notify[256];			/* Program to notify mail arrivation */
-	char action[256];			/* Action to execute on mouse click, reduces to what happens on button1 */
-	char button2[256];			/* What to run on button2. (middle) */
-	char fetchcmd[256];			/* Action for mail fetching for pop3/imap, reduces to what happens on button3 */
+	char label[BUF_SMALL];		/* Printed at left; max 5 chars */
+	char path[BUF_BIG];			/* Path to mailbox */
+	char notify[BUF_BIG];		/* Program to notify mail arrivation */
+	char action[BUF_BIG];		/* Action to execute on mouse click, reduces to
+										 *	what happens on button1. this is executed after
+										 *	either actionnew or actionnonew (if they are
+										 *	defined in the config file) */
+	char actionnew[BUF_BIG];	/* Action to execute on mouse click when new mail */
+	char actionnonew[BUF_BIG];	/* Action to execute on mouse click when no new mail */
+	char actiondc[BUF_BIG];		/* Action to execute when icq is disconnected */
+	char button2[BUF_BIG];		/* What to run on button2. (middle) */
+	char fetchcmd[BUF_BIG];		/* Action for mail fetching for pop3/imap, reduces to what happens on button3 */
 	int fetchinterval;
 	int TotalMsgs;				/* Total messages in mailbox */
 	int UnreadMsgs;				/* New (unread) messages in mailbox */
@@ -65,9 +75,9 @@ typedef struct _mbox_t {
 			unsigned int dircache_flush:1;	/* hack to flush directory caches */
 		} maildir;
 		struct {
-			char password[32];
-			char userName[32];
-			char serverName[256];
+			char password[BUF_SMALL];
+			char userName[BUF_SMALL];
+			char serverName[BUF_BIG];
 			int serverPort;
 			int localPort;
 			char authList[100];
@@ -93,8 +103,6 @@ typedef struct _mbox_t {
 	const char *askpass;
 } mbox_t;
 
-#define BUF_SIZE 1024
-
 /* creation calls must have this prototype */
 int pop3Create( /*@notnull@ */ Pop3 pc, const char *str);
 int imap4Create( /*@notnull@ */ Pop3 pc, const char *str);
diff --git a/wmbiff/Imap4Client.c b/wmbiff/Imap4Client.c
index 3fdf00c..dd8effb 100644
--- a/wmbiff/Imap4Client.c
+++ b/wmbiff/Imap4Client.c
@@ -696,8 +696,13 @@ static void ask_user_for_password( /*@notnull@ */ Pop3 pc, int bFlushCache)
 			password =
 				passwordFor(PCU.userName, PCU.serverName, pc, bFlushCache);
 			if (password != NULL) {
-				strcpy(PCU.password, password);
-				PCU.password_len = strlen(password);
+				if (strlen(password)+1 > BUF_SMALL) {
+					DMA(DEBUG_ERROR, "Password is too long.\n");
+					memset(PCU.password, 0, BUF_SMALL-1);
+				} else {
+					strncpy(PCU.password, password, BUF_SMALL-1);
+					PCU.password_len = strlen(PCU.password);
+				}
 				free(password);
 				ENFROB(PCU.password);
 			}
diff --git a/wmbiff/ShellClient.c b/wmbiff/ShellClient.c
index 7288733..e2d681a 100644
--- a/wmbiff/ShellClient.c
+++ b/wmbiff/ShellClient.c
@@ -189,6 +189,8 @@ int shellCmdCheck(Pop3 pc)
 			pc->UnreadMsgs = 0;
 			pc->TotalMsgs = count_status;
 		}
+	} else if (strcasestr(commandOutput, "unable")) {
+		return -1;
 	} else if (sscanf(commandOutput, "%9s\n", pc->TextStatus) == 1) {
 		/* validate the string input */
 		int i;
@@ -287,7 +289,12 @@ int shellCreate( /*@notnull@ */ Pop3 pc, const char *str)
 	SH_DM(pc, DEBUG_INFO, "path= '%s'\n", commandline);
 	{
 		char *tmp = strdup(commandline);
+		if (strlen(tmp)+1 > BUF_BIG) {
+			SH_DM(pc, DEBUG_ERROR, "commandline '%s' is too long.\n", commandline);
+			memset(pc->path, 0, BUF_BIG);
+		} else {
 		strcpy(pc->path, tmp);
+		}
 		free(tmp);
 	}
 	return 0;
diff --git a/wmbiff/maildirClient.c b/wmbiff/maildirClient.c
index 411f7bd..f68d0c1 100644
--- a/wmbiff/maildirClient.c
+++ b/wmbiff/maildirClient.c
@@ -1,11 +1,11 @@
-/* $Id: maildirClient.c,v 1.13 2003/10/26 07:42:28 bluehal Exp $ */
+/* $Id: maildirClient.c,v 1.14 2004/01/01 07:47:50 bluehal Exp $ */
 /* Author : Yong-iL Joh ( tolkien at mizi.com )
    Modified : Jorge Garc�a ( Jorge.Garcia at uv.es )
    Modified : Dwayne C. Litzenberger ( dlitz at dlitz.net )
  * 
  * Maildir checker.
  *
- * Last Updated : $Date: 2003/10/26 07:42:28 $
+ * Last Updated : $Date: 2004/01/01 07:47:50 $
  *
  */
 
@@ -55,7 +55,7 @@ int maildirCheckHistory(Pop3 pc)
 	struct stat st_new;
 	struct stat st_cur;
 	struct utimbuf ut;
-	char path_new[256], path_cur[256];
+	char path_new[BUF_BIG*2], path_cur[BUF_BIG*2];
 
 	int count_new = 0, count_cur = 0;
 
@@ -69,7 +69,7 @@ int maildirCheckHistory(Pop3 pc)
 	if (pc->u.maildir.dircache_flush) {
 		/* hack to clear directory cache for network-mounted maildirs */
 		int fd;
-		char path_newtmp[512];
+		char path_newtmp[BUF_BIG*2+32];
 		strcpy(path_newtmp, path_new);
 		strcat(path_newtmp, ".wmbiff.dircache_flush.XXXXXX");
 		if ((fd = mkstemp(path_newtmp)) >= 0) {
@@ -164,7 +164,12 @@ int maildirCreate(Pop3 pc, const char *str)
 	} else {
 		i = 0;
 	}
-	strcpy(pc->path, str + 8 + i);	/* cut off ``maildir:'' */
+	if (strlen(str+8+i)+1 > BUF_BIG) {
+		DM(pc, DEBUG_ERROR, "maildir '%s' is too long.\n", str+8+i);
+		memset(pc->path, 0, BUF_BIG);
+	} else {
+		strncpy(pc->path, str + 8 + i, BUF_BIG-1);	/* cut off ``maildir:'' */
+	}
 
 	DM(pc, DEBUG_INFO, "maildir: str = '%s'\n", str);
 	DM(pc, DEBUG_INFO, "maildir: path= '%s'\n", pc->path);
diff --git a/wmbiff/mboxClient.c b/wmbiff/mboxClient.c
index eac4103..f8b907e 100644
--- a/wmbiff/mboxClient.c
+++ b/wmbiff/mboxClient.c
@@ -1,4 +1,4 @@
-/* $Id: mboxClient.c,v 1.15 2002/06/21 04:31:31 bluehal Exp $ */
+/* $Id: mboxClient.c,v 1.16 2004/01/01 07:47:50 bluehal Exp $ */
 /* Author:		Yong-iL Joh <tolkien at mizi.com>
    Modified:	Jorge Garc�a <Jorge.Garcia at uv.es>
    			 	Rob Funk <rfunk at funknet.net>
@@ -6,7 +6,7 @@
  * 
  * MBOX checker.
  *
- * Last Updated : $Date: 2002/06/21 04:31:31 $
+ * Last Updated : $Date: 2004/01/01 07:47:50 $
  *
  */
 
@@ -143,8 +143,14 @@ int mboxCreate(Pop3 pc, const char *str)
 	pc->checkMail = mboxCheckHistory;
 
 	/* default boxes are mbox... cut mbox: if it exists */
-	if (!strncasecmp(pc->path, "mbox:", 5))
-		strcpy(pc->path, str + 5);	/* cut off ``mbox:'' */
+	if (!strncasecmp(pc->path, "mbox:", 5)) {
+		if (strlen(str+5)+1 > BUF_BIG) {
+			DM(pc, DEBUG_ERROR, "mbox '%s' is too long.\n", str+5);
+			memset(pc->path, 0, BUF_BIG);
+		} else {
+			strncpy(pc->path, str + 5, BUF_BIG-1);	/* cut off ``mbox:'' */
+		}
+	}
 
 	DM(pc, DEBUG_INFO, "mbox: str = '%s'\n", str);
 	DM(pc, DEBUG_INFO, "mbox: path= '%s'\n", pc->path);
diff --git a/wmbiff/passwordMgr.c b/wmbiff/passwordMgr.c
index 1745a71..a23ea80 100644
--- a/wmbiff/passwordMgr.c
+++ b/wmbiff/passwordMgr.c
@@ -48,9 +48,9 @@
 
 typedef struct password_binding_struct {
 	struct password_binding_struct *next;
-	char user[32];
-	char server[255];
-	char password[32];			/* may be frobnicated */
+	char user[BUF_SMALL];
+	char server[BUF_BIG];
+	char password[BUF_SMALL];			/* may be frobnicated */
 	unsigned char password_len;	/* frobnicated *'s are nulls */
 } *password_binding;
 
@@ -260,8 +260,18 @@ char *passwordFor(const char *username,
 		}
 #endif
 		retval = strdup(p->password);
-		strcpy(p->user, username);
-		strcpy(p->server, servername);
+		if (strlen(username)+1 > BUF_SMALL) {
+			DM(pc, DEBUG_ERROR, "username is too long.\n");
+			memset(p->user, 0, BUF_SMALL);
+		} else {
+			strncpy(p->user, username, BUF_SMALL-1);
+		}
+		if (strlen(servername)+1 > BUF_BIG) {
+			DM(pc, DEBUG_ERROR, "servername is too long.\n");
+			memset(p->server, 0, BUF_BIG);
+		} else {
+			strncpy(p->server, servername, BUF_BIG-1);
+		}
 		ENFROB(p->password);
 		p->next = pass_list;
 		pass_list = p;
diff --git a/wmbiff/wmbiff.c b/wmbiff/wmbiff.c
index c8250e2..80ee84b 100644
--- a/wmbiff/wmbiff.c
+++ b/wmbiff/wmbiff.c
@@ -1,4 +1,4 @@
-/* $Id: wmbiff.c,v 1.59 2003/11/08 22:17:42 bluehal Exp $ */
+/* $Id: wmbiff.c,v 1.60 2004/01/01 07:47:50 bluehal Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -186,7 +186,7 @@ static int ReadLine(FILE * fp, /*@out@ */ char *setting,
 	/* strcpy(setting, p); nspring replaced with sscanf dec 2002 */
 	strcpy(value, q);
 
-	if (sscanf(p, "%[a-z.]%d", setting, mbox_index) == 2) {
+	if (sscanf(p, "%[_a-z.]%d", setting, mbox_index) == 2) {
 		/* mailbox-specific configuration, ends in a digit */
 		if (*mbox_index < 0 || *mbox_index >= MAX_NUM_MAILBOXES) {
 			DMA(DEBUG_ERROR, "invalid mailbox number %d\n", *mbox_index);
@@ -250,7 +250,7 @@ static void parse_mbox_path(unsigned int item)
 static int Read_Config_File(char *filename, int *loopinterval)
 {
 	FILE *fp;
-	char setting[17], value[BUF_SIZE];
+	char setting[BUF_SMALL], value[BUF_SIZE];
 	int mbox_index;
 	unsigned int i;
 
@@ -295,25 +295,78 @@ static int Read_Config_File(char *filename, int *loopinterval)
 			DMA(DEBUG_ERROR, "Don't have %d mailboxes.\n", mbox_index);
 			continue;
 		}
+
 		if (1U + mbox_index > num_mailboxes
 			&& mbox_index + 1 <= MAX_NUM_MAILBOXES) {
 			num_mailboxes = 1U + mbox_index;
 		}
+
 		/* now only local settings */
 		if (!strcmp(setting, "label.")) {
-			strcpy(mbox[mbox_index].label, value);
+			if (strlen(value)+1 > BUF_SMALL) {
+				DMA(DEBUG_ERROR, "Mailbox %i label string '%s' is too long.\n", mbox_index, value);
+            continue;
+			} else {
+				strncpy(mbox[mbox_index].label, value, BUF_SMALL-1);
+			}
 		} else if (!strcmp(setting, "path.")) {
-			strcpy(mbox[mbox_index].path, value);
+			if (strlen(value)+1 > BUF_BIG) {
+				DMA(DEBUG_ERROR, "Mailbox %i path string '%s' is too long.\n", mbox_index, value);
+            continue;
+			} else {
+				strncpy(mbox[mbox_index].path, value, BUF_BIG-1);
+			}
 		} else if (!strcmp(setting, "notify.")) {
-			strcpy(mbox[mbox_index].notify, value);
+			if (strlen(value)+1 > BUF_BIG) {
+				DMA(DEBUG_ERROR, "Mailbox %i notify string '%s' is too long.\n", mbox_index, value);
+            continue;
+			} else {
+				strncpy(mbox[mbox_index].notify, value, BUF_BIG-1);
+			}
 		} else if (!strcmp(setting, "action.")) {
-			strcpy(mbox[mbox_index].action, value);
+			if (strlen(value)+1 > BUF_BIG) {
+				DMA(DEBUG_ERROR, "Mailbox %i action string '%s' is too long.\n", mbox_index, value);
+            continue;
+			} else {
+				strncpy(mbox[mbox_index].action, value, BUF_BIG-1);
+			}
+		} else if (!strcmp(setting, "action_disconnected.")) {
+			if (strlen(value)+1 > BUF_BIG) {
+				DMA(DEBUG_ERROR, "Mailbox %i action_disconnected string '%s' is too long.\n", mbox_index, value);
+            continue;
+			} else {
+				strncpy(mbox[mbox_index].actiondc, value, BUF_BIG-1);
+			}
+		} else if (!strcmp(setting, "action_new_mail.")) {
+			if (strlen(value)+1 > BUF_BIG) {
+				DMA(DEBUG_ERROR, "Mailbox %i action_new_mail string '%s' is too long.\n", mbox_index, value);
+            continue;
+			} else {
+				strncpy(mbox[mbox_index].actionnew, value, BUF_BIG-1);
+			}
+		} else if (!strcmp(setting, "action_no_new_mail.")) {
+			if (strlen(value)+1 > BUF_BIG) {
+				DMA(DEBUG_ERROR, "Mailbox %i action_no_new_mail string '%s' is too long.\n", mbox_index, value);
+            continue;
+			} else {
+				strncpy(mbox[mbox_index].actionnonew, value, BUF_BIG-1);
+			}
 		} else if (!strcmp(setting, "interval.")) {
 			mbox[mbox_index].loopinterval = atoi(value);
 		} else if (!strcmp(setting, "buttontwo.")) {
-			strcpy(mbox[mbox_index].button2, value);
+			if (strlen(value)+1 > BUF_BIG) {
+				DMA(DEBUG_ERROR, "Mailbox %i buttontwo string '%s' is too long.\n", mbox_index, value);
+            continue;
+			} else {
+				strncpy(mbox[mbox_index].button2, value, BUF_BIG-1);
+			}
 		} else if (!strcmp(setting, "fetchcmd.")) {
-			strcpy(mbox[mbox_index].fetchcmd, value);
+			if (strlen(value)+1 > BUF_BIG) {
+				DMA(DEBUG_ERROR, "Mailbox %i fetchcmd string '%s' is too long.\n", mbox_index, value);
+            continue;
+			} else {
+				strncpy(mbox[mbox_index].fetchcmd, value, BUF_BIG-1);
+			}
 		} else if (!strcmp(setting, "fetchinterval.")) {
 			mbox[mbox_index].fetchinterval = atoi(value);
 		} else if (!strcmp(setting, "debug.")) {
@@ -346,12 +399,15 @@ static void init_biff(char *config_file)
 	unsigned int i;
 
 	for (i = 0; i < MAX_NUM_MAILBOXES; i++) {
-		mbox[i].label[0] = '\0';
-		mbox[i].path[0] = '\0';
-		mbox[i].notify[0] = '\0';
-		mbox[i].action[0] = '\0';
-		mbox[i].button2[0] = '\0';
-		mbox[i].fetchcmd[0] = '\0';
+		memset(mbox[i].label, 0, BUF_SMALL);
+		memset(mbox[i].path, 0, BUF_BIG);
+		memset(mbox[i].notify, 0, BUF_BIG);
+		memset(mbox[i].action, 0, BUF_BIG);
+		memset(mbox[i].actiondc, 0, BUF_BIG);
+		memset(mbox[i].actionnew, 0, BUF_BIG);
+		memset(mbox[i].actionnonew, 0, BUF_BIG);
+		memset(mbox[i].button2, 0, BUF_BIG);
+		memset(mbox[i].fetchcmd, 0, BUF_BIG);
 		mbox[i].loopinterval = 0;
 		mbox[i].getHeaders = NULL;
 		mbox[i].releaseHeaders = NULL;
@@ -380,13 +436,21 @@ static void init_biff(char *config_file)
 		/* setup defaults if there's no config */
 		if ((m = getenv("MAIL")) != NULL) {
 			/* we are using MAIL environment var. type mbox */
+			if (strlen(m)+1 > BUF_BIG) {
+				DMA(DEBUG_ERROR, "MAIL environment var '%s' is too long.\n", m);
+			} else {
 			DMA(DEBUG_INFO, "Using MAIL environment var '%s'.\n", m);
-			strcpy(mbox[0].path, m);
+				strncpy(mbox[0].path, m, BUF_BIG-1);
+			}
 		} else if ((m = getenv("USER")) != NULL) {
 			/* we are using MAIL environment var. type mbox */
+			if (strlen(m)+10+1 > BUF_BIG) {
+				DMA(DEBUG_ERROR, "USER environment var '%s' is too long.\n", m);
+			} else {
 			DMA(DEBUG_INFO, "Using /var/mail/%s.\n", m);
 			strcpy(mbox[0].path, "/var/mail/");
-			strcat(mbox[0].path, m);
+				strncat(mbox[0].path, m, BUF_BIG-1-10);
+			}
 		} else {
 			DMA(DEBUG_ERROR, "Cannot open config file '%s' nor use the "
 				"MAIL environment var.\n", config_file);
@@ -1028,7 +1092,7 @@ static void do_biff(int argc, const char **argv)
 					CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
 				if (but_released_region == but_pressed_region
 					&& but_released_region >= 0) {
-					const char *click_action;
+					const char *click_action, *extra_click_action = NULL;
 
 					switch (Event.xbutton.button) {
 					case 1:	/* Left mouse-click */
@@ -1037,6 +1101,14 @@ static void do_biff(int argc, const char **argv)
 							(Event.xbutton.state & ShiftMask)) {
 							restart_wmbiff(0);
 						}
+						/* do we need to run an extra action? */
+						if (mbox[but_released_region].UnreadMsgs == -1) {
+							extra_click_action = mbox[but_released_region].actiondc;
+						} else if (mbox[but_released_region].UnreadMsgs > 0) {
+							extra_click_action = mbox[but_released_region].actionnew;
+						} else {
+							extra_click_action = mbox[but_released_region].actionnonew;
+						}
 						click_action = mbox[but_released_region].action;
 						break;
 					case 2:	/* Middle mouse-click */
@@ -1049,6 +1121,11 @@ static void do_biff(int argc, const char **argv)
 						click_action = NULL;
 						break;
 					}
+					if (extra_click_action != NULL && extra_click_action[0] != 0 &&
+						strcmp(extra_click_action, "msglst")) {
+						DM(&mbox[but_released_region], DEBUG_INFO, "runing: %s", extra_click_action);
+						(void) execCommand(extra_click_action);
+					}
 					if (click_action != NULL && click_action[0] != '\0'
 						&& strcmp(click_action, "msglst")) {
 						DM(&mbox[but_released_region], DEBUG_INFO,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git



More information about the Pkg-wmaker-commits mailing list