+2008-07-02 10:06 +0200 Rocco Rutte <pdmef@gmx.net> (cc2334fdf126)
+
+ * hash.c: Use casts to avoid triggering integer overflow detection in
+ hash function
+
+2008-07-01 20:06 -0700 Vincent Lefevre <vincent@vinc17.org> (fb0df4ae0836)
+
+ * ChangeLog, curs_lib.c: Clamp timeval math to unsigned int to match
+ progress timestamps. This is fine since only relative differences
+ matter. Closes #3018.
+
2008-07-01 18:29 -0700 Brendan Cully <brendan@kublai.com> (f9af0501d2dd)
* crypt-gpgme.c: Set GPGME locale on first attempt to create context.
continue;
strfcpy (buffer, NONULL(tmp->path), sizeof (buffer));
- mutt_pretty_mailbox (buffer);
+ mutt_pretty_mailbox (buffer, sizeof (buffer));
add_folder (menu, state, buffer, &s, tmp->new);
}
else
{
strfcpy (path, LastDir, sizeof (path));
- mutt_pretty_mailbox (path);
+ mutt_pretty_mailbox (path, sizeof (path));
#ifdef USE_IMAP
if (state->imap_browse && option (OPTIMAPLSUB))
snprintf (title, titlelen, _("Subscribed [%s], File mask: %s"),
continue;
strfcpy (path, tmp->path, sizeof (path));
- mutt_pretty_mailbox (path);
+ mutt_pretty_mailbox (path, sizeof (path));
if (!first && pos + strlen (path) >= COLS - 7)
break;
break;
}
strfcpy (s, tmp->path, slen);
- mutt_pretty_mailbox (s);
+ mutt_pretty_mailbox (s, slen);
break;
default:
break;
}
strfcpy (s, tmp->path, slen);
- mutt_pretty_mailbox (s);
+ mutt_pretty_mailbox (s, slen);
break;
}
}
}
}
- mutt_pretty_mailbox (buf);
+ mutt_pretty_mailbox (buf, sizeof (buf));
if (mutt_enter_fname (prompt, buf, sizeof (buf), redraw, 0) == -1)
return (-1);
strfcpy(pretty, idx[i]->content->filename, sizeof(pretty));
if(stat(idx[i]->content->filename, &st) != 0)
{
- mutt_pretty_mailbox(pretty);
+ mutt_pretty_mailbox(pretty, sizeof (pretty));
mutt_error(_("%s [#%d] no longer exists!"),
pretty, i+1);
return -1;
if(idx[i]->content->stamp < st.st_mtime)
{
- mutt_pretty_mailbox(pretty);
+ mutt_pretty_mailbox(pretty, sizeof (pretty));
snprintf(msg, sizeof(msg), _("%s [#%d] modified. Update encoding?"),
pretty, i+1);
strfcpy (buf, fcc, sizeof (buf));
if (mutt_get_field ("Fcc: ", buf, sizeof (buf), M_FILE | M_CLEAR) == 0)
{
- strfcpy (fcc, buf, _POSIX_PATH_MAX);
- mutt_pretty_mailbox (fcc);
+ strfcpy (fcc, buf, fcclen);
+ mutt_pretty_mailbox (fcc, fcclen);
move (HDR_FCC, HDR_XOFFSET);
mutt_paddstr (W, fcc);
fccSet = 1;
if (Context)
{
strfcpy (fname, NONULL (Context->path), sizeof (fname));
- mutt_pretty_mailbox (fname);
+ mutt_pretty_mailbox (fname, sizeof (fname));
}
if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0])
case OP_COMPOSE_RENAME_FILE:
CHECK_COUNT;
strfcpy (fname, idx[menu->current]->content->filename, sizeof (fname));
- mutt_pretty_mailbox (fname);
+ mutt_pretty_mailbox (fname, sizeof (fname));
if (mutt_get_field (_("Rename to: "), fname, sizeof (fname), M_FILE)
== 0 && fname[0])
{
if (Context)
{
strfcpy (fname, NONULL (Context->path), sizeof (fname));
- mutt_pretty_mailbox (fname);
+ mutt_pretty_mailbox (fname, sizeof (fname));
}
if (idxlen)
msg->content = idx[0]->content;
if ((op == OP_MAIN_NEXT_UNREAD_MAILBOX) && Context && Context->path)
{
strfcpy (buf, Context->path, sizeof (buf));
- mutt_pretty_mailbox (buf);
+ mutt_pretty_mailbox (buf, sizeof (buf));
mutt_buffy (buf, sizeof (buf));
if (!buf[0])
{
set_option (OPTNEEDREDRAW);
if (*buf)
{
- mutt_pretty_mailbox (buf);
+ mutt_pretty_mailbox (buf, buflen);
if (!pass)
mutt_history_add (hclass, buf, 1);
rv = 0;
if (*p)
{
strfcpy (fcc, p, fcclen);
- mutt_pretty_mailbox (fcc);
+ mutt_pretty_mailbox (fcc, fcclen);
}
keep = 0;
}
}
else
{
- mutt_pretty_mailbox (path);
+ mutt_pretty_mailbox (path, sizeof (path));
mutt_error (_("%s: unable to attach file"), path);
}
}
else
strfcpy (path, NONULL (Outbox), pathlen);
}
- mutt_pretty_mailbox (path);
+ mutt_pretty_mailbox (path, pathlen);
}
static char *_mutt_string_hook (const char *match, int hook)
{
/* reformat output */
imap_qualify_path (dest, dlen, &mx, completion);
- mutt_pretty_mailbox (dest);
+ mutt_pretty_mailbox (dest, dlen);
FREE (&mx.mbox);
return 0;
{
_tmp[0] = '\0';
strfcpy (_tmp, NONULL(*((char **) MuttVars[idx].data)), sizeof (_tmp));
- mutt_pretty_mailbox (_tmp);
+ mutt_pretty_mailbox (_tmp, sizeof (_tmp));
val = _tmp;
}
else
{
strfcpy (tmp, NONULL (*((char **) MuttVars[idx].data)), sizeof (tmp));
if (DTYPE (MuttVars[idx].type) == DT_PATH)
- mutt_pretty_mailbox (tmp);
+ mutt_pretty_mailbox (tmp, sizeof (tmp));
}
else if (DTYPE (MuttVars[idx].type) == DT_ADDR)
{
rename (tempfile, savefile);
mutt_unblock_signals ();
mx_fastclose_mailbox (ctx);
- mutt_pretty_mailbox (savefile);
+ mutt_pretty_mailbox (savefile, sizeof (savefile));
mutt_error (_("Write failed! Saved partial mailbox to %s"), savefile);
mutt_sleep (5);
return (-1);
}
/* collapse the pathname using ~ or = when possible */
-void mutt_pretty_mailbox (char *s)
+void mutt_pretty_mailbox (char *s, size_t buflen)
{
char *p = s, *q = s;
size_t len;
url_scheme_t scheme;
+ char tmp[_POSIX_PATH_MAX];
scheme = url_check_scheme (s);
q = strchr (p, '\0');
p = q;
}
-
- /* first attempt to collapse the pathname */
- while (*p)
+
+ /* cleanup path */
+ if (strstr (p, "//") || strstr (p, "/./"))
{
- if (*p == '/' && p[1] == '/')
- {
- *q++ = '/';
- p += 2;
- }
- else if (p[0] == '/' && p[1] == '.' && p[2] == '/')
+ /* first attempt to collapse the pathname, this is more
+ * lightweight than realpath() and doesn't resolve links
+ */
+ while (*p)
{
- *q++ = '/';
- p += 3;
+ if (*p == '/' && p[1] == '/')
+ {
+ *q++ = '/';
+ p += 2;
+ }
+ else if (p[0] == '/' && p[1] == '.' && p[2] == '/')
+ {
+ *q++ = '/';
+ p += 3;
+ }
+ else
+ *q++ = *p++;
}
- else
- *q++ = *p++;
+ *q = 0;
}
- *q = 0;
+ else if (strstr (p, "..") &&
+ (scheme == U_UNKNOWN || scheme == U_FILE) &&
+ realpath (p, tmp))
+ strfcpy (p, tmp, buflen - (p - s));
if (mutt_strncmp (s, Maildir, (len = mutt_strlen (Maildir))) == 0 &&
s[len] == '/')
p = tmp->data + 11;
SKIPWS (p);
strfcpy (fcc, p, fcclen);
- mutt_pretty_mailbox (fcc);
+ mutt_pretty_mailbox (fcc, fcclen);
/* remove the X-Mutt-Fcc: header field */
next = tmp->next;
void mutt_perror (const char *);
void mutt_prepare_envelope (ENVELOPE *, int);
void mutt_unprepare_envelope (ENVELOPE *);
-void mutt_pretty_mailbox (char *);
+void mutt_pretty_mailbox (char *, size_t);
void mutt_pretty_size (char *, size_t, LOFF_T);
void mutt_pipe_message (HEADER *);
void mutt_print_message (HEADER *);
char path[_POSIX_PATH_MAX];
strfcpy (path, aptr->content->filename, sizeof (path));
- mutt_pretty_mailbox (path);
+ mutt_pretty_mailbox (path, sizeof (path));
mutt_format_s (dest, destlen, prefix, path);
}
else
main_loop:
fcc_error = 0; /* reset value since we may have failed before */
- mutt_pretty_mailbox (fcc);
+ mutt_pretty_mailbox (fcc, sizeof (fcc));
i = mutt_compose_menu (msg, fcc, sizeof (fcc), cur);
if (i == -1)
{
if (Context && Context->path)
{
strfcpy (tmp, Context->path, sizeof (tmp));
- mutt_pretty_mailbox (tmp);
+ mutt_pretty_mailbox (tmp, sizeof (tmp));
}
else
strfcpy (tmp, _("(no mailbox)"), sizeof (tmp));