sm-commit AT lists.ibiblio.org
Subject: Source Mage code commit list
List archive
[SM-Commit] GIT changes to master grimoire by Florian Franzmann (82b136dd177b961c6ce4988a4a7773e7fb604eab)
- From: Florian Franzmann <scm AT sourcemage.org>
- To: sm-commit AT lists.ibiblio.org
- Subject: [SM-Commit] GIT changes to master grimoire by Florian Franzmann (82b136dd177b961c6ce4988a4a7773e7fb604eab)
- Date: Sun, 24 Apr 2016 18:51:24 +0000
GIT changes to master grimoire by Florian Franzmann
<siflfran AT hawo.stw.uni-erlangen.de>:
mail/mutt/01-bug-fixes.patch | 813
+++++++++++++++++++++++++++++++++++++++++++
1 file changed, 813 insertions(+)
New commits:
commit 82b136dd177b961c6ce4988a4a7773e7fb604eab
Author: Florian Franzmann <siflfran AT hawo.stw.uni-erlangen.de>
Commit: Florian Franzmann <siflfran AT hawo.stw.uni-erlangen.de>
mail/mutt: add missing patch file
diff --git a/mail/mutt/01-bug-fixes.patch b/mail/mutt/01-bug-fixes.patch
new file mode 100644
index 0000000..c28cc54
--- /dev/null
+++ b/mail/mutt/01-bug-fixes.patch
@@ -0,0 +1,813 @@
+diff -urN --exclude .git mutt-1.6.0/alias.c mutt-1.6.0-bug-fixes/alias.c
+--- mutt-1.6.0/alias.c 2016-04-04 17:53:36.431839450 +0100
++++ mutt-1.6.0-bug-fixes/alias.c 2016-04-04 17:53:36.946847627 +0100
+@@ -27,6 +27,7 @@
+
+ #include <string.h>
+ #include <ctype.h>
++#include <errno.h>
+
+ ADDRESS *mutt_lookup_alias (const char *s)
+ {
+@@ -379,8 +380,10 @@
+ recode_buf (buf, sizeof (buf));
+ write_safe_address (rc, buf);
+ fputc ('\n', rc);
+- safe_fclose (&rc);
+- mutt_message _("Alias added.");
++ if (safe_fsync_close(&rc) != 0)
++ mutt_message ("Trouble adding alias: %s.", strerror(errno));
++ else
++ mutt_message _("Alias added.");
+ }
+ else
+ mutt_perror (buf);
+diff -urN --exclude .git mutt-1.6.0/attach.c mutt-1.6.0-bug-fixes/attach.c
+--- mutt-1.6.0/attach.c 2016-04-04 17:53:36.432839466 +0100
++++ mutt-1.6.0-bug-fixes/attach.c 2016-04-04 17:53:36.946847627 +0100
+@@ -765,7 +765,7 @@
+ fseeko ((s.fpin = fp), m->offset, 0);
+ mutt_decode_attachment (m, &s);
+
+- if (fclose (s.fpout) != 0)
++ if (safe_fsync_close (&s.fpout) != 0)
+ {
+ mutt_perror ("fclose");
+ mutt_sleep (2);
+@@ -800,7 +800,10 @@
+ return (-1);
+ }
+ safe_fclose (&ofp);
+- safe_fclose (&nfp);
++ if (safe_fsync_close (&nfp) != 0) {
++ mutt_error _("Write fault!");
++ return (-1);
++ }
+ }
+
+ return 0;
+@@ -814,6 +817,7 @@
+ unsigned int saved_encoding = 0;
+ BODY *saved_parts = NULL;
+ HEADER *saved_hdr = NULL;
++ int ret = 0;
+
+ memset (&s, 0, sizeof (s));
+ s.flags = displaying;
+@@ -871,7 +875,10 @@
+
+ mutt_body_handler (m, &s);
+
+- safe_fclose (&s.fpout);
++ if (safe_fsync_close (&s.fpout) != 0) {
++ mutt_perror("fclose");
++ ret = -1;
++ }
+ if (fp == NULL)
+ {
+ m->length = 0;
+@@ -885,7 +892,7 @@
+ safe_fclose (&s.fpin);
+ }
+
+- return (0);
++ return ret;
+ }
+
+ /* Ok, the difference between send and receive:
+diff -urN --exclude .git mutt-1.6.0/browser.c mutt-1.6.0-bug-fixes/browser.c
+--- mutt-1.6.0/browser.c 2016-04-04 17:53:36.433839482 +0100
++++ mutt-1.6.0-bug-fixes/browser.c 2016-04-04 17:53:36.946847627 +0100
+@@ -29,6 +29,7 @@
+ #include "sort.h"
+ #include "mailbox.h"
+ #include "browser.h"
++#include "mx.h"
+ #ifdef USE_IMAP
+ #include "imap.h"
+ #endif
+@@ -86,6 +87,16 @@
+ return ((BrowserSort & SORT_REVERSE) ? -r : r);
+ }
+
++static int browser_compare_desc (const void *a, const void *b)
++{
++ struct folder_file *pa = (struct folder_file *) a;
++ struct folder_file *pb = (struct folder_file *) b;
++
++ int r = mutt_strcoll (pa->desc, pb->desc);
++
++ return ((BrowserSort & SORT_REVERSE) ? -r : r);
++}
++
+ static int browser_compare_date (const void *a, const void *b)
+ {
+ struct folder_file *pa = (struct folder_file *) a;
+@@ -106,6 +117,26 @@
+ return ((BrowserSort & SORT_REVERSE) ? -r : r);
+ }
+
++static int browser_compare_count (const void *a, const void *b)
++{
++ struct folder_file *pa = (struct folder_file *) a;
++ struct folder_file *pb = (struct folder_file *) b;
++
++ int r = pa->all - pb->all;
++
++ return ((BrowserSort & SORT_REVERSE) ? -r : r);
++}
++
++static int browser_compare_count_new (const void *a, const void *b)
++{
++ struct folder_file *pa = (struct folder_file *) a;
++ struct folder_file *pb = (struct folder_file *) b;
++
++ int r = pa->new - pb->new;
++
++ return ((BrowserSort & SORT_REVERSE) ? -r : r);
++}
++
+ static void browser_sort (struct browser_state *state)
+ {
+ int (*f) (const void *, const void *);
+@@ -120,6 +151,15 @@
+ case SORT_SIZE:
+ f = browser_compare_size;
+ break;
++ case SORT_DESC:
++ f = browser_compare_desc;
++ break;
++ case SORT_COUNT:
++ f = browser_compare_count;
++ break;
++ case SORT_COUNT_NEW:
++ f = browser_compare_count_new;
++ break;
+ case SORT_SUBJECT:
+ default:
+ f = browser_compare_subject;
+@@ -260,7 +300,16 @@
+ else
+ mutt_format_s (dest, destlen, fmt, "");
+ break;
+-
++
++ case 'n':
++ if (!optional) {
++ snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
++ snprintf (dest, destlen, tmp, folder->ff->all);
++ } else if (!folder->ff->all) {
++ optional = 0;
++ }
++ break;
++
+ case 'N':
+ #ifdef USE_IMAP
+ if (mx_is_imap (folder->ff->desc))
+@@ -325,7 +374,8 @@
+ }
+
+ static void add_folder (MUTTMENU *m, struct browser_state *state,
+- const char *name, const struct stat *s, unsigned int
new)
++ const char *name, const char *desc,
++ const struct stat *s, unsigned int new, unsigned int
all)
+ {
+ if (state->entrylen == state->entrymax)
+ {
+@@ -349,8 +399,9 @@
+ }
+
+ (state->entry)[state->entrylen].new = new;
++ (state->entry)[state->entrylen].all = all;
+ (state->entry)[state->entrylen].name = safe_strdup (name);
+- (state->entry)[state->entrylen].desc = safe_strdup (name);
++ (state->entry)[state->entrylen].desc = safe_strdup(desc ? desc : name);
+ #ifdef USE_IMAP
+ (state->entry)[state->entrylen].imap = 0;
+ #endif
+@@ -432,7 +483,7 @@
+ tmp = Incoming;
+ while (tmp && mutt_strcmp (buffer, tmp->path))
+ tmp = tmp->next;
+- add_folder (menu, state, de->d_name, &s, (tmp) ? tmp->new : 0);
++ add_folder (menu, state, de->d_name, NULL, &s, (tmp) ? tmp->new : 0, 0);
+ }
+ closedir (dp);
+ browser_sort (state);
+@@ -460,14 +511,14 @@
+ if (mx_is_imap (tmp->path))
+ {
+ imap_mailbox_state (tmp->path, &mbox);
+- add_folder (menu, state, tmp->path, NULL, mbox.new);
++ add_folder (menu, state, tmp->path, NULL, NULL, mbox.new,
mbox.messages);
+ continue;
+ }
+ #endif
+ #ifdef USE_POP
+ if (mx_is_pop (tmp->path))
+ {
+- add_folder (menu, state, tmp->path, NULL, tmp->new);
++ add_folder (menu, state, tmp->path, NULL, NULL, tmp->new, 0);
+ continue;
+ }
+ #endif
+@@ -496,7 +547,7 @@
+ strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
+ mutt_pretty_mailbox (buffer, sizeof (buffer));
+
+- add_folder (menu, state, buffer, &s, tmp->new);
++ add_folder (menu, state, buffer, NULL, &s, tmp->new, 0);
+ }
+ while ((tmp = tmp->next));
+ browser_sort (state);
+@@ -1136,9 +1187,9 @@
+ int reverse = (i == OP_SORT_REVERSE);
+
+ switch (mutt_multi_choice ((reverse) ?
+- _("Reverse sort by (d)ate, (a)lpha, si(z)e or do(n)'t sort? ") :
+- _("Sort by (d)ate, (a)lpha, si(z)e or do(n)'t sort? "),
+- _("dazn")))
++ _("Reverse sort by (d)ate, (a)lpha, si(z)e, d(e)scription,
(c)ount, ne(w) count, or do(n)'t sort? ") :
++ _("Sort by (d)ate, (a)lpha, si(z)e, d(e)scription, (c)ount,
ne(w) count, or do(n)'t sort? "),
++ _("dazecwn")))
+ {
+ case -1: /* abort */
+ resort = 0;
+@@ -1156,7 +1207,19 @@
+ BrowserSort = SORT_SIZE;
+ break;
+
+- case 4: /* do(n)'t sort */
++ case 4: /* d(e)scription */
++ BrowserSort = SORT_DESC;
++ break;
++
++ case 5: /* (c)ount */
++ BrowserSort = SORT_COUNT;
++ break;
++
++ case 6: /* ne(w) count */
++ BrowserSort = SORT_COUNT_NEW;
++ break;
++
++ case 7: /* do(n)'t sort */
+ BrowserSort = SORT_ORDER;
+ resort = 0;
+ break;
+diff -urN --exclude .git mutt-1.6.0/browser.h mutt-1.6.0-bug-fixes/browser.h
+--- mutt-1.6.0/browser.h 2016-04-04 17:53:36.433839482 +0100
++++ mutt-1.6.0-bug-fixes/browser.h 2016-04-04 17:53:36.854846166 +0100
+@@ -30,6 +30,8 @@
+ char *desc;
+
+ unsigned int new;
++ unsigned int all;
++
+ #ifdef USE_IMAP
+ char delim;
+
+diff -urN --exclude .git mutt-1.6.0/configure.ac
mutt-1.6.0-bug-fixes/configure.ac
+--- mutt-1.6.0/configure.ac 2016-04-04 17:53:36.435839513 +0100
++++ mutt-1.6.0-bug-fixes/configure.ac 2016-04-04 17:53:36.948847659 +0100
+@@ -313,6 +313,7 @@
+ AC_CHECK_HEADERS(unix.h)
+
+ AC_CHECK_FUNCS(setrlimit getsid)
++AC_CHECK_FUNCS(fgets_unlocked fgetc_unlocked)
+
+ AC_MSG_CHECKING(for sig_atomic_t in signal.h)
+ AC_EGREP_HEADER(sig_atomic_t,signal.h,
+@@ -354,7 +355,7 @@
+
+ AC_CHECK_FUNCS(fgetpos memmove setegid srand48 strerror)
+
+-AC_REPLACE_FUNCS([setenv strcasecmp strdup strsep strtok_r wcscasecmp])
++AC_REPLACE_FUNCS([setenv strcasecmp strdup strndup strnlen strsep strtok_r
wcscasecmp])
+ AC_REPLACE_FUNCS([strcasestr mkdtemp])
+
+ AC_CHECK_FUNC(getopt)
+diff -urN --exclude .git mutt-1.6.0/curs_main.c
mutt-1.6.0-bug-fixes/curs_main.c
+--- mutt-1.6.0/curs_main.c 2016-04-04 17:53:36.438839561 +0100
++++ mutt-1.6.0-bug-fixes/curs_main.c 2016-04-04 17:53:36.950847691 +0100
+@@ -118,7 +118,9 @@
+ {
+ char *term = getenv("TERM");
+ char *tcaps;
++#ifdef HAVE_USE_EXTENDED_NAMES
+ int tcapi;
++#endif
+ char **termp;
+ char *known[] = {
+ "color-xterm",
+diff -urN --exclude .git mutt-1.6.0/globals.h mutt-1.6.0-bug-fixes/globals.h
+--- mutt-1.6.0/globals.h 2016-04-04 17:53:36.444839656 +0100
++++ mutt-1.6.0-bug-fixes/globals.h 2016-04-04 17:53:36.953847738 +0100
+@@ -192,8 +192,6 @@
+ extern unsigned char QuadOptions[];
+ #endif
+
+-WHERE unsigned short Counter INITVAL (0);
+-
+ WHERE short ConnectTimeout;
+ WHERE short HistSize;
+ WHERE short MenuContext;
+diff -urN --exclude .git mutt-1.6.0/init.c mutt-1.6.0-bug-fixes/init.c
+--- mutt-1.6.0/init.c 2016-04-04 17:53:36.449839736 +0100
++++ mutt-1.6.0-bug-fixes/init.c 2016-04-04 17:53:36.957847802 +0100
+@@ -2867,23 +2867,6 @@
+ return 0;
+ }
+
+-static void mutt_srandom (void)
+-{
+- struct timeval tv;
+- unsigned seed;
+-
+- gettimeofday(&tv, NULL);
+- /* POSIX.1-2008 states that seed is 'unsigned' without specifying its
width.
+- * Use as many of the lower order bits from the current time of day as
the seed.
+- * If the upper bound is truncated, that is fine.
+- *
+- * tv_sec is integral of type integer or float. Cast to 'long long'
before
+- * bitshift in case it is a float.
+- */
+- seed = ((LONGLONG) tv.tv_sec << 20) | tv.tv_usec;
+- srandom(seed);
+-}
+-
+ void mutt_init (int skip_sys_rc, LIST *commands)
+ {
+ struct passwd *pw;
+@@ -2902,13 +2885,9 @@
+ ReverseAlias = hash_create (1031, 1);
+
+ mutt_menu_init ();
+- mutt_srandom ();
+
+- /*
+- * XXX - use something even more difficult to predict?
+- */
+ snprintf (AttachmentMarker, sizeof (AttachmentMarker),
+- "\033]9;%ld\a", (long) time (NULL));
++ "\033]9;%" PRIu64 "\a", mutt_rand64());
+
+ /* on one of the systems I use, getcwd() does not return the same prefix
+ as is listed in the passwd file */
+diff -urN --exclude .git mutt-1.6.0/init.h mutt-1.6.0-bug-fixes/init.h
+--- mutt-1.6.0/init.h 2016-04-04 17:53:36.451839767 +0100
++++ mutt-1.6.0-bug-fixes/init.h 2016-04-04 17:53:36.958847818 +0100
+@@ -3046,7 +3046,10 @@
+ ** entries are sorted alphabetically. Valid values:
+ ** .il
+ ** .dd alpha (alphabetically)
++ ** .dd count (all message count)
+ ** .dd date
++ ** .dd desc (description)
++ ** .dd new (new message count)
+ ** .dd size
+ ** .dd unsorted
+ ** .ie
+@@ -3631,7 +3634,10 @@
+
+ const struct mapping_t SortBrowserMethods[] = {
+ { "alpha", SORT_SUBJECT },
++ { "count", SORT_COUNT },
+ { "date", SORT_DATE },
++ { "desc", SORT_DESC },
++ { "new", SORT_COUNT_NEW },
+ { "size", SORT_SIZE },
+ { "unsorted", SORT_ORDER },
+ { NULL, 0 }
+diff -urN --exclude .git mutt-1.6.0/lib.c mutt-1.6.0-bug-fixes/lib.c
+--- mutt-1.6.0/lib.c 2016-04-04 17:53:36.452839783 +0100
++++ mutt-1.6.0-bug-fixes/lib.c 2016-04-04 17:53:36.959847834 +0100
+@@ -219,8 +219,10 @@
+ {
+ if (fflush (*f) || fsync (fileno (*f)))
+ {
++ int save_errno = errno;
+ r = -1;
+ safe_fclose (f);
++ errno = save_errno;
+ }
+ else
+ r = safe_fclose (f);
+@@ -367,6 +369,7 @@
+ size -= chunk;
+ }
+
++ if (fflush(out) != 0) return -1;
+ return 0;
+ }
+
+@@ -381,6 +384,7 @@
+ return (-1);
+ }
+
++ if (fflush(fout) != 0) return -1;
+ return 0;
+ }
+
+diff -urN --exclude .git mutt-1.6.0/main.c mutt-1.6.0-bug-fixes/main.c
+--- mutt-1.6.0/main.c 2016-04-04 17:53:36.452839783 +0100
++++ mutt-1.6.0-bug-fixes/main.c 2016-04-04 17:53:36.959847834 +0100
+@@ -598,7 +598,7 @@
+
+ mutt_error = mutt_nocurses_error;
+ mutt_message = mutt_nocurses_error;
+- SRAND (time (NULL));
++ (void)mutt_rand32();
+ umask (077);
+
+ memset (Options, 0, sizeof (Options));
+diff -urN --exclude .git mutt-1.6.0/mbyte.c mutt-1.6.0-bug-fixes/mbyte.c
+--- mutt-1.6.0/mbyte.c 2016-04-04 17:53:36.453839799 +0100
++++ mutt-1.6.0-bug-fixes/mbyte.c 2016-04-04 17:53:36.959847834 +0100
+@@ -107,7 +107,7 @@
+ char buf[MB_LEN_MAX+1];
+ ICONV_CONST char *ib;
+ char *ob;
+- size_t ibl, obl, r;
++ size_t ibl, obl;
+
+ if (s)
+ {
+@@ -117,7 +117,7 @@
+ ib = buf;
+ ob = s;
+ obl = MB_LEN_MAX;
+- r = iconv (cd, &ib, &ibl, &ob, &obl);
++ iconv (cd, &ib, &ibl, &ob, &obl);
+ }
+ else
+ {
+@@ -125,7 +125,7 @@
+ ibl = 1;
+ ob = buf;
+ obl = sizeof (buf);
+- r = iconv (cd, &ib, &ibl, &ob, &obl);
++ iconv (cd, &ib, &ibl, &ob, &obl);
+ }
+ return ob - s;
+ }
+diff -urN --exclude .git mutt-1.6.0/mh.c mutt-1.6.0-bug-fixes/mh.c
+--- mutt-1.6.0/mh.c 2016-04-04 17:53:36.453839799 +0100
++++ mutt-1.6.0-bug-fixes/mh.c 2016-04-04 17:53:36.960847850 +0100
+@@ -304,8 +304,8 @@
+ omask = umask (mh_umask (dest));
+ FOREVER
+ {
+- snprintf (path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%d",
+- dest->path, NONULL (Hostname), (int) getpid (), Counter++);
++ snprintf (path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%" PRIu64,
++ dest->path, NONULL (Hostname), (int) getpid (), mutt_rand64());
+ if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1)
+ {
+ if (errno != EEXIST)
+@@ -1313,9 +1313,9 @@
+ omask = umask (mh_umask (dest));
+ FOREVER
+ {
+- snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%lld.%u_%d.%s%s",
+- dest->path, subdir, (long long)time (NULL), (unsigned
int)getpid (),
+- Counter++, NONULL (Hostname), suffix);
++ snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%lld.R%" PRIu64 ".%s%s",
++ dest->path, subdir, (long long)time (NULL), mutt_rand64(),
++ NONULL (Hostname), suffix);
+
+ dprint (2, (debugfile, "maildir_open_new_message (): Trying %s.\n",
+ path));
+@@ -1399,8 +1399,8 @@
+ /* construct a new file name. */
+ FOREVER
+ {
+- snprintf (path, _POSIX_PATH_MAX, "%s/%lld.%u_%d.%s%s", subdir,
+- (long long)time (NULL), (unsigned int)getpid (), Counter++,
++ snprintf (path, _POSIX_PATH_MAX, "%s/%lld.R%" PRIu64 ".%s%s", subdir,
++ (long long)time (NULL), mutt_rand64(),
+ NONULL (Hostname), suffix);
+ snprintf (full, _POSIX_PATH_MAX, "%s/%s", ctx->path, path);
+
+diff -urN --exclude .git mutt-1.6.0/mutt.h mutt-1.6.0-bug-fixes/mutt.h
+--- mutt-1.6.0/mutt.h 2016-04-04 17:53:36.454839815 +0100
++++ mutt-1.6.0-bug-fixes/mutt.h 2016-04-04 17:53:36.960847850 +0100
+@@ -52,6 +52,11 @@
+ #include <limits.h>
+ #endif
+
++/* PATH_MAX is undefined on the hurd */
++#ifndef PATH_MAX
++#define PATH_MAX _POSIX_PATH_MAX
++#endif
++
+ #include <pwd.h>
+ #include <grp.h>
+
+@@ -66,6 +71,14 @@
+ # define MB_LEN_MAX 16
+ #endif
+
++#ifdef HAVE_FGETS_UNLOCKED
++# define fgets fgets_unlocked
++#endif
++
++#ifdef HAVE_FGETC_UNLOCKED
++# define fgetc fgetc_unlocked
++#endif
++
+ /* nifty trick I stole from ELM 2.5alpha. */
+ #ifdef MAIN_C
+ #define WHERE
+diff -urN --exclude .git mutt-1.6.0/muttlib.c mutt-1.6.0-bug-fixes/muttlib.c
+--- mutt-1.6.0/muttlib.c 2016-04-04 17:53:36.456839847 +0100
++++ mutt-1.6.0-bug-fixes/muttlib.c 2016-04-04 17:53:36.962847881 +0100
+@@ -37,6 +37,7 @@
+ #include <string.h>
+ #include <ctype.h>
+ #include <unistd.h>
++#include <sys/syscall.h>
+ #include <stdlib.h>
+ #include <sys/wait.h>
+ #include <errno.h>
+@@ -771,12 +772,79 @@
+ mutt_free_envelope(extra);
+ }
+
++static FILE *frandom;
++
++void mutt_randbuf(void *out, size_t len)
++{
++ if (len > 1048576) {
++ mutt_error (_("mutt_randbuf len=%zu"), len);
++ exit(1);
++ }
++ /* XXX switch to HAVE_GETRANDOM and getrandom() in about 2017 */
++#if defined(SYS_getrandom) && defined(__linux__)
++ static int whined;
++ long ret;
++ do {
++ ret = syscall(SYS_getrandom, out, len, 0, 0, 0, 0);
++ } while ((ret == -1) && (errno == EINTR));
++ if (ret == len) return;
++ if (!whined) {
++ mutt_error (_("getrandom failed: %s"), strerror(errno));
++ mutt_sleep (1);
++ whined = 1;
++ }
++ /* let's try urandom in case user has configured selinux or something
++ * to not allow getrandom */
++#endif
++ if (frandom == NULL) {
++ frandom = fopen("/dev/urandom", "rb");
++ if (frandom == NULL) {
++ mutt_error (_("open /dev/urandom: %s"), strerror(errno));
++ exit(1);
++ }
++ setbuf(frandom, NULL);
++ }
++ if (fread(out, 1, len, frandom) != len) {
++ mutt_error (_("read /dev/urandom: %s"), strerror(errno));
++ exit(1);
++ }
++}
++
++static const unsigned char base32[] = "abcdefghijklmnopqrstuvwxyz234567";
++
++void mutt_rand_base32(void *out, size_t len)
++{
++ size_t pos;
++ uint8_t *p = out;
++
++ mutt_randbuf(p, len);
++ for (pos = 0; pos < len; pos++)
++ p[pos] = base32[p[pos] % 32];
++}
++
++uint32_t mutt_rand32(void)
++{
++ uint32_t ret;
++
++ mutt_randbuf(&ret, sizeof(ret));
++ return ret;
++}
++
++uint64_t mutt_rand64(void)
++{
++ uint64_t ret;
++
++ mutt_randbuf(&ret, sizeof(ret));
++ return ret;
++}
++
++
+ void _mutt_mktemp (char *s, size_t slen, const char *prefix, const char
*suffix,
+ const char *src, int line)
+ {
+- size_t n = snprintf (s, slen, "%s/%s-%s-%d-%d-%ld%ld%s%s",
++ size_t n = snprintf (s, slen, "%s/%s-%s-%d-%d-%" PRIu64 "%s%s",
+ NONULL (Tempdir), NONULL (prefix), NONULL (Hostname),
+- (int) getuid (), (int) getpid (), random (), random (),
++ (int) getuid (), (int) getpid (), mutt_rand64(),
+ suffix ? "." : "", NONULL (suffix));
+ if (n >= slen)
+ dprint (1, (debugfile, "%s:%d: ERROR: insufficient buffer space to hold
temporary filename! slen=%zu but need %zu\n",
+diff -urN --exclude .git mutt-1.6.0/mutt_ssl.c
mutt-1.6.0-bug-fixes/mutt_ssl.c
+--- mutt-1.6.0/mutt_ssl.c 2016-04-04 17:53:36.455839831 +0100
++++ mutt-1.6.0-bug-fixes/mutt_ssl.c 2016-04-04 17:53:36.961847865 +0100
+@@ -432,14 +432,6 @@
+ if (!ssl_check_certificate (conn, ssldata))
+ return -1;
+
+- /* L10N:
+- %1$s is version (e.g. "TLSv1.2")
+- %2$s is cipher_version (e.g. "TLSv1/SSLv3")
+- %3$s is cipher_name (e.g. "ECDHE-RSA-AES128-GCM-SHA256") */
+- mutt_message (_("%s connection using %s (%s)"),
+- SSL_get_version(ssldata->ssl), SSL_get_cipher_version (ssldata->ssl),
SSL_get_cipher_name (ssldata->ssl));
+- mutt_sleep (0);
+-
+ return 0;
+ }
+
+diff -urN --exclude .git mutt-1.6.0/protos.h mutt-1.6.0-bug-fixes/protos.h
+--- mutt-1.6.0/protos.h 2016-04-04 17:53:36.482840260 +0100
++++ mutt-1.6.0-bug-fixes/protos.h 2016-04-04 17:53:36.980848167 +0100
+@@ -1,5 +1,6 @@
+ /*
+ * Copyright (C) 1996-2000,2007,2010,2013 Michael R. Elkins <me AT mutt.org>
++ * Copyright (C) 2013 Karel Zak <kzak AT redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+@@ -375,6 +376,11 @@
+ void mutt_set_header_color(CONTEXT *, HEADER *);
+ void mutt_sleep (short);
+ int mutt_save_confirm (const char *, struct stat *);
++void mutt_randbuf(void *out, size_t len);
++#define MUTT_RANDTAG_LEN (16)
++void mutt_rand_base32(void *out, size_t len);
++uint32_t mutt_rand32(void);
++uint64_t mutt_rand64(void);
+
+ int mh_valid_message (const char *);
+
+@@ -422,16 +428,6 @@
+ #define LONGLONG long
+ #endif
+
+-#ifdef HAVE_SRAND48
+-#define LRAND lrand48
+-#define SRAND srand48
+-#define DRAND drand48
+-#else
+-#define LRAND rand
+-#define SRAND srand
+-#define DRAND (double)rand
+-#endif /* HAVE_SRAND48 */
+-
+ /* HP-UX, ConvexOS and UNIXware don't have this macro */
+ #ifndef S_ISLNK
+ #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK ? 1 : 0)
+@@ -565,3 +561,11 @@
+ #ifndef HAVE_MKDTEMP
+ char *mkdtemp (char *tmpl);
+ #endif
++
++#ifndef HAVE_STRNLEN
++size_t strnlen(const char *s, size_t maxlen);
++#endif
++
++#ifndef HAVE_STRNDUP
++char *strndup(const char *s, size_t n);
++#endif
+diff -urN --exclude .git mutt-1.6.0/sendlib.c mutt-1.6.0-bug-fixes/sendlib.c
+--- mutt-1.6.0/sendlib.c 2016-04-04 17:53:36.484840291 +0100
++++ mutt-1.6.0-bug-fixes/sendlib.c 2016-04-04 17:53:36.982848199 +0100
+@@ -73,8 +73,6 @@
+ '8', '9', '+', '/'
+ };
+
+-static char MsgIdPfx = 'A';
+-
+ static void transform_to_7bit (BODY *a, FILE *fpin);
+
+ static void encode_quoted (FGETCONV * fc, FILE *fout, int istext)
+@@ -480,18 +478,12 @@
+
+ #undef write_as_text_part
+
+-#define BOUNDARYLEN 16
+ void mutt_generate_boundary (PARAMETER **parm)
+ {
+- char rs[BOUNDARYLEN + 1];
+- char *p = rs;
+- int i;
+-
+- rs[BOUNDARYLEN] = 0;
+- for (i=0;i<BOUNDARYLEN;i++)
+- *p++ = B64Chars[LRAND() % sizeof (B64Chars)];
+- *p = 0;
++ char rs[MUTT_RANDTAG_LEN + 1];
+
++ mutt_rand_base32(rs, sizeof(rs) - 1);
++ rs[MUTT_RANDTAG_LEN] = 0;
+ mutt_set_parameter ("boundary", rs, parm);
+ }
+
+@@ -2133,16 +2125,18 @@
+ time_t now;
+ struct tm *tm;
+ const char *fqdn;
++ unsigned char rndid[MUTT_RANDTAG_LEN + 1];
+
++ mutt_rand_base32(rndid, sizeof(rndid) - 1);
++ rndid[MUTT_RANDTAG_LEN] = 0;
+ now = time (NULL);
+ tm = gmtime (&now);
+ if(!(fqdn = mutt_fqdn(0)))
+ fqdn = NONULL(Hostname);
+
+- snprintf (buf, sizeof (buf), "<%d%02d%02d%02d%02d%02d.G%c%u@%s>",
++ snprintf (buf, sizeof (buf), "<%d%02d%02d%02d%02d%02d.%s@%s>",
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
+- tm->tm_min, tm->tm_sec, MsgIdPfx, (unsigned int)getpid (), fqdn);
+- MsgIdPfx = (MsgIdPfx == 'Z') ? 'A' : MsgIdPfx + 1;
++ tm->tm_min, tm->tm_sec, rndid, fqdn);
+ return (safe_strdup (buf));
+ }
+
+@@ -2559,9 +2553,12 @@
+ mutt_copy_header (fp, h, f, ch_flags, NULL);
+ fputc ('\n', f);
+ mutt_copy_bytes (fp, f, h->content->length);
+- safe_fclose (&f);
+ FREE (&msgid_str);
+-
++ if (safe_fclose (&f) != 0) {
++ mutt_perror(tempfile);
++ unlink(tempfile);
++ return -1;
++ }
+ #if USE_SMTP
+ if (SmtpUrl)
+ ret = mutt_smtp_send (env_from, to, NULL, NULL, tempfile,
+diff -urN --exclude .git mutt-1.6.0/sort.h mutt-1.6.0-bug-fixes/sort.h
+--- mutt-1.6.0/sort.h 2016-04-04 17:53:36.485840307 +0100
++++ mutt-1.6.0-bug-fixes/sort.h 2016-04-04 17:53:36.983848215 +0100
+@@ -31,6 +31,9 @@
+ #define SORT_KEYID 12
+ #define SORT_TRUST 13
+ #define SORT_SPAM 14
++#define SORT_DESC 15
++#define SORT_COUNT 16
++#define SORT_COUNT_NEW 17
+ /* dgc: Sort & SortAux are shorts, so I'm bumping these bitflags up from
+ * bits 4 & 5 to bits 8 & 9 to make room for more sort keys in the future.
*/
+ #define SORT_MASK 0xff
+diff -urN --exclude .git mutt-1.6.0/strndup.c mutt-1.6.0-bug-fixes/strndup.c
+--- mutt-1.6.0/strndup.c 1970-01-01 01:00:00.000000000 +0100
++++ mutt-1.6.0-bug-fixes/strndup.c 2016-04-04 17:53:36.906846992 +0100
+@@ -0,0 +1,19 @@
++/*
++ * Copyright (C) 2013 Karel Zak <kzak AT redhat.com>
++ */
++
++#if HAVE_CONFIG_H
++# include "config.h"
++#endif
++
++#include "mutt.h"
++
++char *strndup(const char *s, size_t n)
++{
++ size_t len = strnlen(s, n);
++ char *new = (char *) malloc((len + 1) * sizeof(char));
++ if (!new)
++ return NULL;
++ new[len] = '\0';
++ return (char *) memcpy(new, s, len);
++}
+diff -urN --exclude .git mutt-1.6.0/strnlen.c mutt-1.6.0-bug-fixes/strnlen.c
+--- mutt-1.6.0/strnlen.c 1970-01-01 01:00:00.000000000 +0100
++++ mutt-1.6.0-bug-fixes/strnlen.c 2016-04-04 17:53:36.906846992 +0100
+@@ -0,0 +1,20 @@
++/*
++ * Copyright (C) 2013 Karel Zak <kzak AT redhat.com>
++ */
++
++#if HAVE_CONFIG_H
++# include "config.h"
++#endif
++
++#include "mutt.h"
++
++size_t strnlen(const char *s, size_t maxlen)
++{
++ int i;
++
++ for (i = 0; i < maxlen; i++) {
++ if (s[i] == '\0')
++ return i + 1;
++ }
++ return maxlen;
++}
- [SM-Commit] GIT changes to master grimoire by Florian Franzmann (82b136dd177b961c6ce4988a4a7773e7fb604eab), Florian Franzmann, 04/24/2016
Archive powered by MHonArc 2.6.24.