File truncate.patch of Package mutt
---
bcache.c | 2 +-
browser.c | 6 +++---
buffy.c | 4 ++--
commands.c | 2 +-
imap/browse.c | 2 +-
imap/imap.c | 18 +++++++++---------
imap/imap_private.h | 2 +-
imap/message.c | 2 +-
lib.c | 2 +-
lib.h | 2 +-
mh.c | 23 +++++++++++++----------
mutt_sasl.c | 2 +-
mutt_ssl_gnutls.c | 18 +++++++++---------
pager.c | 2 +-
pgppubring.c | 2 +-
smime.c | 2 +-
sort.c | 2 +-
17 files changed, 48 insertions(+), 45 deletions(-)
--- bcache.c
+++ bcache.c 2018-07-17 09:42:34.633928921 +0000
@@ -128,7 +128,7 @@ FILE* mutt_bcache_get(body_cache_t *bcac
FILE* mutt_bcache_put(body_cache_t *bcache, const char *id, int tmp)
{
- char path[_POSIX_PATH_MAX];
+ char path[_POSIX_PATH_MAX+64];
FILE* fp;
char* s;
struct stat sb;
--- browser.c
+++ browser.c 2018-07-17 09:42:34.633928921 +0000
@@ -502,7 +502,7 @@ static int examine_directory (MUTTMENU *
static int examine_mailboxes (MUTTMENU *menu, struct browser_state *state)
{
struct stat s;
- char buffer[LONG_STRING];
+ char buffer[LONG_STRING+16];
BUFFY *tmp = Incoming;
if (!Incoming)
@@ -548,7 +548,7 @@ static int examine_mailboxes (MUTTMENU *
if (mx_is_maildir (tmp->path))
{
struct stat st2;
- char md[_POSIX_PATH_MAX];
+ char md[_POSIX_PATH_MAX+16];
snprintf (md, sizeof (md), "%s/new", tmp->path);
if (stat (md, &s) < 0)
@@ -635,7 +635,7 @@ static int file_tag (MUTTMENU *menu, int
void _mutt_select_file (char *f, size_t flen, int flags, char ***files, int *numfiles)
{
- char buf[_POSIX_PATH_MAX];
+ char buf[_POSIX_PATH_MAX+16];
char prefix[_POSIX_PATH_MAX] = "";
char helpstr[LONG_STRING];
char title[STRING];
--- buffy.c
+++ buffy.c 2018-07-17 09:42:34.637928849 +0000
@@ -313,8 +313,8 @@ int mutt_parse_mailboxes (BUFFER *path,
static int buffy_maildir_check_dir (BUFFY* mailbox, const char *dir_name, int check_new,
int check_stats)
{
- char path[_POSIX_PATH_MAX];
- char msgpath[_POSIX_PATH_MAX];
+ char path[2*_POSIX_PATH_MAX+8];
+ char msgpath[2*_POSIX_PATH_MAX+8];
DIR *dirp;
struct dirent *de;
char *p;
--- commands.c
+++ commands.c 2018-07-17 09:42:34.637928849 +0000
@@ -241,7 +241,7 @@ int mutt_display_message (HEADER *cur)
void ci_bounce_message (HEADER *h)
{
- char prompt[SHORT_STRING];
+ char prompt[SHORT_STRING+16];
char scratch[SHORT_STRING];
char buf[HUGE_STRING] = { 0 };
ADDRESS *adr = NULL;
--- imap/browse.c
+++ imap/browse.c 2018-07-17 09:42:34.637928849 +0000
@@ -43,7 +43,7 @@ int imap_browse (char* path, struct brow
{
IMAP_DATA* idata;
IMAP_LIST list;
- char buf[LONG_STRING];
+ char buf[LONG_STRING+64];
char mbox[LONG_STRING];
char munged_mbox[LONG_STRING];
char list_cmd[5];
--- imap/imap.c
+++ imap/imap.c 2018-07-17 09:44:01.836348503 +0000
@@ -59,7 +59,7 @@ int imap_access (const char* path)
{
IMAP_DATA* idata;
IMAP_MBOX mx;
- char buf[LONG_STRING];
+ char buf[LONG_STRING+64];
char mailbox[LONG_STRING];
char mbox[LONG_STRING];
int rc;
@@ -115,7 +115,7 @@ int imap_access (const char* path)
int imap_create_mailbox (IMAP_DATA* idata, char* mailbox)
{
- char buf[LONG_STRING], mbox[LONG_STRING];
+ char buf[LONG_STRING+16], mbox[LONG_STRING];
imap_munge_mbox_name (idata, mbox, sizeof (mbox), mailbox);
snprintf (buf, sizeof (buf), "CREATE %s", mbox);
@@ -133,7 +133,7 @@ int imap_rename_mailbox (IMAP_DATA* idat
{
char oldmbox[LONG_STRING];
char newmbox[LONG_STRING];
- char buf[LONG_STRING];
+ char buf[2*LONG_STRING+64];
imap_munge_mbox_name (idata, oldmbox, sizeof (oldmbox), mx->mbox);
imap_munge_mbox_name (idata, newmbox, sizeof (newmbox), newname);
@@ -148,7 +148,7 @@ int imap_rename_mailbox (IMAP_DATA* idat
int imap_delete_mailbox (CONTEXT* ctx, IMAP_MBOX mx)
{
- char buf[LONG_STRING], mbox[LONG_STRING];
+ char buf[LONG_STRING+16], mbox[LONG_STRING];
IMAP_DATA *idata;
if (!ctx || !ctx->data) {
@@ -588,7 +588,7 @@ static int imap_open_mailbox (CONTEXT* c
IMAP_DATA *idata;
IMAP_STATUS* status;
char buf[LONG_STRING];
- char bufout[LONG_STRING];
+ char bufout[LONG_STRING+64];
int count = 0;
IMAP_MBOX mx, pmx;
int rc;
@@ -1572,7 +1572,7 @@ int imap_buffy_check (int force, int che
IMAP_DATA* lastdata = NULL;
BUFFY* mailbox;
char name[LONG_STRING];
- char command[LONG_STRING];
+ char command[LONG_STRING+64];
char munged[LONG_STRING];
int buffies = 0;
@@ -1663,7 +1663,7 @@ int imap_status (char* path, int queue)
static int queued = 0;
IMAP_DATA *idata;
- char buf[LONG_STRING];
+ char buf[LONG_STRING+64];
char mbox[LONG_STRING];
IMAP_STATUS* status;
@@ -1927,7 +1927,7 @@ int imap_search (CONTEXT* ctx, const pat
int imap_subscribe (char *path, int subscribe)
{
IMAP_DATA *idata;
- char buf[LONG_STRING];
+ char buf[LONG_STRING+64];
char mbox[LONG_STRING];
char errstr[STRING];
int mblen;
@@ -2057,7 +2057,7 @@ imap_complete_hosts (char *dest, size_t
int imap_complete(char* dest, size_t dlen, char* path) {
IMAP_DATA* idata;
char list[LONG_STRING];
- char buf[LONG_STRING];
+ char buf[LONG_STRING+64];
IMAP_LIST listresp;
char completion[LONG_STRING];
int clen;
--- imap/imap_private.h
+++ imap/imap_private.h 2018-07-17 09:42:34.641928776 +0000
@@ -73,7 +73,7 @@
#define IMAP_CMD_POLL (1<<3)
/* length of "DD-MMM-YYYY HH:MM:SS +ZZzz" (null-terminated) */
-#define IMAP_DATELEN 27
+#define IMAP_DATELEN 37
enum
{
--- imap/message.c
+++ imap/message.c 2018-07-17 09:42:34.641928776 +0000
@@ -753,7 +753,7 @@ int imap_append_message (CONTEXT *ctx, M
{
IMAP_DATA* idata;
FILE *fp;
- char buf[LONG_STRING];
+ char buf[LONG_STRING+IMAP_DATELEN+SHORT_STRING+64];
char mbox[LONG_STRING];
char mailbox[LONG_STRING];
char internaldate[IMAP_DATELEN];
--- lib.c
+++ lib.c 2018-07-17 09:42:34.637928849 +0000
@@ -583,7 +583,7 @@ int mutt_rmtree (const char* path)
{
DIR* dirp;
struct dirent* de;
- char cur[_POSIX_PATH_MAX];
+ char cur[2*_POSIX_PATH_MAX+16];
struct stat statbuf;
int rc = 0;
--- lib.h
+++ lib.h 2018-07-17 09:42:34.637928849 +0000
@@ -59,7 +59,7 @@
# define HUGE_STRING 8192
# define LONG_STRING 1024
-# define STRING 256
+# define STRING 512
# define SHORT_STRING 128
/*
--- mh.c
+++ mh.c 2018-07-17 09:42:34.637928849 +0000
@@ -852,7 +852,7 @@ static int maildir_parse_dir (CONTEXT *
if (subdir)
{
- char tmp[_POSIX_PATH_MAX];
+ char tmp[2*_POSIX_PATH_MAX+16];
snprintf (tmp, sizeof (tmp), "%s/%s", subdir, de->d_name);
h->path = safe_strdup (tmp);
}
@@ -1406,7 +1406,7 @@ static void maildir_flags (char *dest, s
if (hdr && (hdr->flagged || hdr->replied || hdr->read || hdr->deleted || hdr->old || hdr->maildir_flags))
{
- char tmp[LONG_STRING];
+ char tmp[LONG_STRING], *ptr;
snprintf (tmp, sizeof (tmp),
"%s%s%s%s%s",
hdr->flagged ? "F" : "",
@@ -1415,7 +1415,10 @@ static void maildir_flags (char *dest, s
NONULL(hdr->maildir_flags));
if (hdr->maildir_flags)
qsort (tmp, strlen (tmp), 1, ch_compar);
- snprintf (dest, destlen, ":2,%s", tmp);
+ /* snprintf (dest, destlen, ":2,%s", tmp); */
+ strcpy(dest, ":2,");
+ ptr = stpncpy(dest+3, tmp, destlen-3);
+ *ptr = '\0';
}
}
@@ -1561,7 +1564,7 @@ static int _maildir_commit_message (CONT
char subdir[4];
char suffix[16];
char path[_POSIX_PATH_MAX];
- char full[_POSIX_PATH_MAX];
+ char full[2*_POSIX_PATH_MAX+16];
char *s;
if (safe_fsync_close (&msg->fp))
@@ -1586,7 +1589,7 @@ static int _maildir_commit_message (CONT
snprintf (path, _POSIX_PATH_MAX, "%s/%lld.%u_%d.%s%s", subdir,
(long long)time (NULL), (unsigned int)getpid (), Counter++,
NONULL (Hostname), suffix);
- snprintf (full, _POSIX_PATH_MAX, "%s/%s", ctx->path, path);
+ snprintf (full, sizeof(full), "%s/%s", ctx->path, path);
dprint (2, (debugfile, "_maildir_commit_message (): renaming %s to %s.\n",
msg->path, full));
@@ -1825,9 +1828,9 @@ static int maildir_sync_message (CONTEXT
/* we just have to rename the file. */
char newpath[_POSIX_PATH_MAX];
- char partpath[_POSIX_PATH_MAX];
- char fullpath[_POSIX_PATH_MAX];
- char oldpath[_POSIX_PATH_MAX];
+ char partpath[_POSIX_PATH_MAX+64];
+ char fullpath[2*_POSIX_PATH_MAX+16];
+ char oldpath[2*_POSIX_PATH_MAX+16];
char suffix[16];
char *p;
@@ -2371,9 +2374,9 @@ static int mh_check_mailbox (CONTEXT * c
static FILE *_maildir_open_find_message (const char *folder, const char *unique,
const char *subfolder)
{
- char dir[_POSIX_PATH_MAX];
+ char dir[2*_POSIX_PATH_MAX+16];
char tunique[_POSIX_PATH_MAX];
- char fname[_POSIX_PATH_MAX];
+ char fname[3*_POSIX_PATH_MAX];
DIR *dp;
struct dirent *de;
--- mutt_sasl.c
+++ mutt_sasl.c 2018-07-17 09:42:34.637928849 +0000
@@ -80,7 +80,7 @@ static int getnameinfo_err(int ret)
* a protection buffer. */
#define MUTT_SASL_MAXBUF 65536
-#define IP_PORT_BUFLEN 1024
+#define IP_PORT_BUFLEN (NI_MAXHOST+NI_MAXSERV+8)
static sasl_callback_t mutt_sasl_callbacks[5];
--- mutt_ssl_gnutls.c
+++ mutt_ssl_gnutls.c 2018-07-17 09:42:34.637928849 +0000
@@ -862,7 +862,7 @@ static int tls_check_one_certificate (co
menu->max = 25;
menu->dialog = (char **) safe_calloc (1, menu->max * sizeof (char *));
for (i = 0; i < menu->max; i++)
- menu->dialog[i] = (char *) safe_calloc (1, SHORT_STRING * sizeof (char));
+ menu->dialog[i] = (char *) safe_calloc (1, STRING * sizeof (char));
mutt_push_current_menu (menu);
row = 0;
@@ -898,10 +898,10 @@ static int tls_check_one_certificate (co
dn_country, &buflen) != 0)
dn_country[0] = '\0';
- snprintf (menu->dialog[row++], SHORT_STRING, " %s %s", dn_common_name, dn_email);
- snprintf (menu->dialog[row++], SHORT_STRING, " %s", dn_organization);
- snprintf (menu->dialog[row++], SHORT_STRING, " %s", dn_organizational_unit);
- snprintf (menu->dialog[row++], SHORT_STRING, " %s %s %s",
+ snprintf (menu->dialog[row++], STRING, " %s %s", dn_common_name, dn_email);
+ snprintf (menu->dialog[row++], STRING, " %s", dn_organization);
+ snprintf (menu->dialog[row++], STRING, " %s", dn_organizational_unit);
+ snprintf (menu->dialog[row++], STRING, " %s %s %s",
dn_locality, dn_province, dn_country);
row++;
@@ -937,10 +937,10 @@ static int tls_check_one_certificate (co
dn_country, &buflen) != 0)
dn_country[0] = '\0';
- snprintf (menu->dialog[row++], SHORT_STRING, " %s %s", dn_common_name, dn_email);
- snprintf (menu->dialog[row++], SHORT_STRING, " %s", dn_organization);
- snprintf (menu->dialog[row++], SHORT_STRING, " %s", dn_organizational_unit);
- snprintf (menu->dialog[row++], SHORT_STRING, " %s %s %s",
+ snprintf (menu->dialog[row++], STRING, " %s %s", dn_common_name, dn_email);
+ snprintf (menu->dialog[row++], STRING, " %s", dn_organization);
+ snprintf (menu->dialog[row++], STRING, " %s", dn_organizational_unit);
+ snprintf (menu->dialog[row++], STRING, " %s %s %s",
dn_locality, dn_province, dn_country);
row++;
--- pager.c
+++ pager.c 2018-07-17 09:42:34.637928849 +0000
@@ -1911,7 +1911,7 @@ mutt_pager (const char *banner, const ch
{
static char searchbuf[STRING] = "";
char buffer[LONG_STRING];
- char helpstr[SHORT_STRING*2];
+ char helpstr[LONG_STRING+SHORT_STRING*2+16];
char tmphelp[SHORT_STRING*2];
int i, ch = 0, rc = -1;
int err, first = 1;
--- pgppubring.c
+++ pgppubring.c 2018-07-17 09:42:34.637928849 +0000
@@ -86,7 +86,7 @@ int main (int argc, char * const argv[])
char *env_pgppath, *env_home;
char pgppath[_POSIX_PATH_MAX];
- char kring[_POSIX_PATH_MAX];
+ char kring[_POSIX_PATH_MAX+64];
while ((c = getopt (argc, argv, "f25sk:S")) != EOF)
{
--- smime.c
+++ smime.c 2018-07-17 09:42:34.637928849 +0000
@@ -179,7 +179,7 @@ static const char *_mutt_fmt_smime_comma
if (!optional)
{
char path[_POSIX_PATH_MAX];
- char buf1[LONG_STRING], buf2[LONG_STRING];
+ char buf1[LONG_STRING], buf2[LONG_STRING+16];
struct stat sb;
strfcpy (path, NONULL (SmimeCALocation), sizeof (path));
--- sort.c
+++ sort.c 2018-07-17 09:42:34.637928849 +0000
@@ -40,7 +40,7 @@ static sort_t *AuxSort = NULL;
unset_option(OPTAUXSORT); \
} \
if (!code) \
- code = (*((HEADER **)a))->index - (*((HEADER **)b))->index;
+ code = (*((HEADER **)a))->index - (*((HEADER **)b))->index
static int compare_score (const void *a, const void *b)
{