[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mutt-dev
Subject:    Bugfixes for Mutt 1.4.1
From:       Christian Biere <cbiere () TechFak ! Uni-Bielefeld ! DE>
Date:       2003-04-29 23:48:34
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Hi,

the attached patch fixes several subtle bugs:

- Fixed type of argument for isdigit(), isalpha() et al.
- Fixed a few snprintf-arguments: pid_t != int etc.
- snprintf.c: Use int instead of short int with va_arg();
	This fixes a crash when trying to open folder imap://bla:3/
	and also fixes a compiliation problem with the `as' on
	IRIX/mips.

Please, also use the newer xregex.h and xregex2.h (from binutils)
because the outdated _regex.h shipped with mutt causes compile- and
runtime problems (on e.g., Solaris 2.8).

Christian

["mutt-1.4.1.udif" (text/plain)]

--- extlib.c	2000/04/22 08:47:31	1.1
+++ extlib.c	2003/04/14 16:23:41
@@ -27,6 +27,7 @@
 #define WHERE
 #define _EXTLIB_C
 
+#include <stdlib.h>
 #include "lib.h"
 
 void (*mutt_error) (const char *, ...) = mutt_nocurses_error;
--- handler.c	2002/03/26 09:49:51	1.1
+++ handler.c	2003/04/14 16:37:32
@@ -159,7 +159,8 @@
     return 1;
   
   /* quoted-printable triple */
-  if (*s == '=' && isxdigit (*(s+1)) && isxdigit (*(s+2)))
+  if (*s == '=' && isxdigit ((unsigned char) *(s+1))
+		  && isxdigit ((unsigned char) *(s+2)))
   {
     *d = (hexval (*(s+1)) << 4) | hexval (*(s+2));
     return 0;
--- imap/command.c	2002/04/07 21:19:57	1.1
+++ imap/command.c	2003/04/29 20:58:11
@@ -301,7 +301,7 @@
 
   s = imap_next_word (idata->cmd.buf);
 
-  if ((idata->state == IMAP_SELECTED) && isdigit (*s))
+  if ((idata->state == IMAP_SELECTED) && isdigit ((unsigned char) *s))
   {
     pn = s;
     s = imap_next_word (s);
@@ -518,7 +518,7 @@
   /* zero out current rights set */
   memset (idata->rights, 0, sizeof (idata->rights));
 
-  while (*s && !isspace(*s))
+  while (*s && !isspace((unsigned char) *s))
   {
     switch (*s) 
     {
--- imap/imap.c	2002/04/07 21:19:57	1.1
+++ imap/imap.c	2003/04/14 16:08:27
@@ -1217,7 +1217,7 @@
       {
 	s = imap_next_word (s);
 	s = imap_next_word (s);
-	if (isdigit (*s))
+	if (isdigit ((unsigned char) *s))
 	{
 	  if (*s != '0')
 	  {
--- imap/message.c	2002/04/07 21:19:57	1.1
+++ imap/message.c	2003/04/29 22:00:24
@@ -435,7 +435,7 @@
   rewind (fp);
   
   imap_munge_mbox_name (mbox, sizeof (mbox), mailbox);
-  snprintf (buf, sizeof (buf), "APPEND %s (\\Seen) {%d}", mbox, len);
+  snprintf (buf, sizeof (buf), "APPEND %s (\\Seen) {%d}", mbox, (int) len);
 
   imap_cmd_start (idata, buf);
 
@@ -848,7 +848,7 @@
       s += 11;
       SKIPWS (s);
       ptmp = tmp;
-      while (isdigit (*s))
+      while (isdigit ((unsigned char) *s))
         *ptmp++ = *s++;
       *ptmp = 0;
       h->content_length = atoi (tmp);
--- imap/util.c	2002/04/29 12:09:21	1.1
+++ imap/util.c	2003/04/29 20:47:34
@@ -148,7 +148,7 @@
     }
   
     if (n > 1) {
-      if (sscanf (tmp, ":%hd%127s", &(mx->account.port), tmp) >= 1)
+      if (sscanf (tmp, ":%hu%127s", &(mx->account.port), tmp) >= 1)
 	mx->account.flags |= M_ACCT_PORT;
       if (sscanf (tmp, "/%s", tmp) == 1)
       {
@@ -325,7 +325,7 @@
     return (-1);
   pc++;
   pn = pc;
-  while (isdigit (*pc))
+  while (isdigit ((unsigned char) *pc))
     pc++;
   *pc = 0;
   *bytes = atoi(pn);
--- init.c	2002/07/24 08:41:29	1.1
+++ init.c	2003/04/29 22:03:07
@@ -143,7 +143,8 @@
 	case 'C':
 	    if (!*tok->dptr)
 		return -1; /* premature end of token */
-	  mutt_buffer_addch (dest, (toupper (*tok->dptr) - '@') & 0x7f);
+	  mutt_buffer_addch (dest,
+			  (toupper ((unsigned char) *tok->dptr) - '@') & 0x7f);
 	  tok->dptr++;
 	  break;
 	case 'r':
@@ -184,7 +185,7 @@
       else if (ch == '[')
 	mutt_buffer_addch (dest, '\033');
       else if (isalpha ((unsigned char) ch))
-	mutt_buffer_addch (dest, toupper (ch) - '@');
+	mutt_buffer_addch (dest, toupper ((unsigned char) ch) - '@');
       else
       {
 	mutt_buffer_addch (dest, '^');
--- lib.c	2002/04/29 17:12:18	1.1
+++ lib.c	2003/04/29 21:55:56
@@ -162,7 +162,7 @@
 
   while (*p)
   {
-    *p = tolower (*p);
+    *p = tolower ((unsigned char) *p);
     p++;
   }
 
@@ -595,7 +595,11 @@
 
   while (*(p = haystack))
   {
-    for (q = needle; *p && *q && tolower (*p) == tolower (*q); p++, q++)
+    for (
+      q = needle;
+      *p && *q && tolower ((unsigned char) *p) == tolower ((unsigned char) *q);
+      p++, q++
+	)
       ;
     if (!*q)
       return (haystack);
--- makedoc.c	2001/01/08 16:33:57	1.1
+++ makedoc.c	2003/04/29 21:27:00
@@ -218,7 +218,7 @@
 
 static char *skip_ws (char *s)
 {
-  while (*s && isspace (*s))
+  while (*s && isspace ((unsigned char) *s))
     s++;
 
   return s;
@@ -300,7 +300,7 @@
     }
     else if (!is_quoted && strchr (single_char_tokens, *t))
       break;
-    else if (!is_quoted && isspace (*t))
+    else if (!is_quoted && isspace ((unsigned char) *t))
       break;
     else
       *d++ = *t;
@@ -486,14 +486,14 @@
     {
       /* heuristic! */
       strncpy (t, s + 5, l);
-      for (; *t; t++) *t = tolower (*t);
+      for (; *t; t++) *t = tolower ((unsigned char) *t);
       break;
     }
     case DT_MAGIC:
     {
       /* heuristic! */
       strncpy (t, s + 2, l);
-      for (; *t; t++) *t = tolower (*t);
+      for (; *t; t++) *t = tolower ((unsigned char) *t);
       break;
     }
     case DT_STR:
@@ -1188,7 +1188,7 @@
       else
       {
 	ref = s;
-	while (isalnum (*s) || *s == '-' || *s == '_')
+	while (isalnum ((unsigned char) *s) || *s == '-' || *s == '_')
 	  ++s;
 
 	docstat = commit_buff (buff, &d, out, docstat);
--- mbox.c	2002/02/28 07:59:24	1.1
+++ mbox.c	2003/04/14 16:37:34
@@ -953,8 +953,9 @@
     
     char savefile[_POSIX_PATH_MAX];
     
-    snprintf (savefile, sizeof (savefile), "%s/mutt.%s-%s-%d",
-	      NONULL (Tempdir), NONULL(Username), NONULL(Hostname), getpid ());
+    snprintf (savefile, sizeof (savefile), "%s/mutt.%s-%s-%ld",
+	      NONULL (Tempdir), NONULL(Username), NONULL(Hostname),
+	      (long) getpid ());
     rename (tempfile, savefile);
     mutt_unblock_signals ();
     mx_fastclose_mailbox (ctx);
--- mh.c	2002/09/09 21:17:20	1.1
+++ mh.c	2003/04/29 20:56:32
@@ -829,9 +829,9 @@
 
   FOREVER
   {
-    snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%ld.%d_%d.%s%s",
-	     dest->path, subdir, time (NULL), getpid (), Counter++,
-	     NONULL (Hostname), suffix);
+    snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%ld.%ld_%d.%s%s",
+	     dest->path, subdir, (long) time (NULL), (long) getpid (),
+	     Counter++, NONULL (Hostname), suffix);
 
     dprint (2, (debugfile, "maildir_open_new_message (): Trying %s.\n",
 		path));
@@ -910,8 +910,9 @@
   /* construct a new file name. */
   FOREVER
   {
-    snprintf (path, _POSIX_PATH_MAX, "%s/%ld.%d_%d.%s%s", subdir,
-	      time (NULL), getpid(), Counter++, NONULL (Hostname), suffix);
+    snprintf (path, _POSIX_PATH_MAX, "%s/%ld.%ld_%d.%s%s", subdir,
+	      (long) time (NULL), (long) getpid(), Counter++,
+	      NONULL (Hostname), suffix);
     snprintf (full, _POSIX_PATH_MAX, "%s/%s", ctx->path, path);
 
     dprint (2, (debugfile, "maildir_commit_message (): renaming %s to %s.\n",
--- muttlib.c	2002/03/25 11:29:32	1.1
+++ muttlib.c	2003/04/29 21:55:31
@@ -516,7 +516,7 @@
       memmove (&dest[idx + pwnl], &dest[idx + 1],
 	       MAX(destlen - idx - pwnl - 1, 0));
       memcpy (&dest[idx], pw->pw_name, MIN(destlen - idx - 1, pwnl));
-      dest[idx] = toupper (dest[idx]);
+      dest[idx] = toupper ((unsigned char) dest[idx]);
     }
   }
       
--- pattern.c	2002/05/18 05:39:55	1.1
+++ pattern.c	2003/04/29 21:58:24
@@ -292,12 +292,12 @@
     }
     else
       pat->min = strtol (s->dptr, &tmp, 0);
-    if (toupper (*tmp) == 'K') /* is there a prefix? */
+    if (toupper ((unsigned char) *tmp) == 'K') /* is there a prefix? */
     {
       pat->min *= 1024;
       tmp++;
     }
-    else if (toupper (*tmp) == 'M')
+    else if (toupper ((unsigned char) *tmp) == 'M')
     {
       pat->min *= 1048576;
       tmp++;
@@ -326,12 +326,12 @@
   {
     /* range maximum */
     pat->max = strtol (tmp, &tmp, 0);
-    if (toupper (*tmp) == 'K')
+    if (toupper ((unsigned char) *tmp) == 'K')
     {
       pat->max *= 1024;
       tmp++;
     }
-    else if (toupper (*tmp) == 'M')
+    else if (toupper ((unsigned char) *tmp) == 'M')
     {
       pat->max *= 1048576;
       tmp++;
--- regex.c	2001/01/08 23:09:30	1.1
+++ regex.c	2003/04/29 23:29:02
@@ -27,7 +27,7 @@
 /*
  * Modifications:
  * 
- * Use _regex.h instead of regex.h.  tlr, 1999-01-06
+ * Use xregex.h instead of regex.h. 
  * Make REGEX_MALLOC depend on HAVE_ALLOCA &c.
  * 				     tlr, 1999-02-14
  * Don't switch on regex debugging when debugging mutt.
@@ -203,7 +203,8 @@
 
 /* Changed to fit into mutt - tlr, 1999-01-06 */
 
-#include "_regex.h"
+#include "xregex.h"
+#include "xregex2.h"
 
 /* isalpha etc. are used for the character classes.  */
 #include <ctype.h>
--- rfc2047.c	2002/04/20 07:26:10	1.1
+++ rfc2047.c	2003/04/29 21:56:56
@@ -606,9 +606,9 @@
 	charset[t-pp] = '\0';
 	break;
       case 3:
-	if (toupper (*pp) == 'Q')
+	if (toupper ((unsigned char) *pp) == 'Q')
 	  enc = ENCQUOTEDPRINTABLE;
-	else if (toupper (*pp) == 'B')
+	else if (toupper ((unsigned char) *pp) == 'B')
 	  enc = ENCBASE64;
 	else
 	{
--- rfc2231.c	2001/02/13 22:06:14	1.1
+++ rfc2231.c	2003/04/14 16:37:39
@@ -135,7 +135,7 @@
     else
     {
       *s = '\0'; s++; /* let s point to the first character of index. */
-      for (t = s; *t && isdigit (*t); t++)
+      for (t = s; *t && isdigit ((unsigned char) *t); t++)
 	;
       encoded = (*t == '*');
       *t = '\0';
@@ -208,7 +208,8 @@
 
   for (d = dest; *src; src++)
   {
-    if (*src == '%' && isxdigit (*(src + 1)) && isxdigit (*(src + 2)))
+    if (*src == '%' && isxdigit ((unsigned char) *(src + 1))
+		    && isxdigit ((unsigned char) *(src + 2)))
     {
       *d++ = (hexval (*(src + 1)) << 4) | (hexval (*(src + 2)));
       src += 2;
--- sendlib.c	2002/05/31 16:59:39	1.1
+++ sendlib.c	2003/04/14 16:37:39
@@ -1750,9 +1750,9 @@
   if(!(fqdn = mutt_fqdn(0)))
     fqdn = NONULL(Hostname);
 
-  snprintf (buf, sizeof (buf), "<%d%02d%02d%02d%02d%02d.G%c%d@%s>",
+  snprintf (buf, sizeof (buf), "<%d%02d%02d%02d%02d%02d.G%c%ld@%s>",
 	    tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
-	    tm->tm_min, tm->tm_sec, MsgIdPfx, getpid (), fqdn);
+	    tm->tm_min, tm->tm_sec, MsgIdPfx, (long) getpid (), fqdn);
   MsgIdPfx = (MsgIdPfx == 'Z') ? 'A' : MsgIdPfx + 1;
   return (safe_strdup (buf));
 }
--- snprintf.c	2001/01/08 16:57:20	1.1
+++ snprintf.c	2003/04/29 23:11:53
@@ -247,7 +247,7 @@
       case 'd':
       case 'i':
 	if (cflags == DP_C_SHORT) 
-	  value = va_arg (args, short int);
+	  value = va_arg (args, int);
 	else if (cflags == DP_C_LONG)
 	  value = va_arg (args, long int);
 	else
@@ -257,7 +257,7 @@
       case 'o':
 	flags |= DP_F_UNSIGNED;
 	if (cflags == DP_C_SHORT)
-	  value = va_arg (args, unsigned short int);
+	  value = va_arg (args, unsigned int);
 	else if (cflags == DP_C_LONG)
 	  value = va_arg (args, unsigned long int);
 	else
@@ -267,7 +267,7 @@
       case 'u':
 	flags |= DP_F_UNSIGNED;
 	if (cflags == DP_C_SHORT)
-	  value = va_arg (args, unsigned short int);
+	  value = va_arg (args, unsigned int);
 	else if (cflags == DP_C_LONG)
 	  value = va_arg (args, unsigned long int);
 	else
@@ -279,7 +279,7 @@
       case 'x':
 	flags |= DP_F_UNSIGNED;
 	if (cflags == DP_C_SHORT)
-	  value = va_arg (args, unsigned short int);
+	  value = va_arg (args, unsigned int);
 	else if (cflags == DP_C_LONG)
 	  value = va_arg (args, unsigned long int);
 	else

[Attachment #6 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic