Skip to content

Commit

Permalink
merge: upstream fixes (mutt/default)
Browse files Browse the repository at this point in the history
 * Fix improper signed int conversion of IMAP uid and msn values.
 * Change imap literal counts to parse and store unsigned ints.
 * Fix imap status count range check.
 * cmd_handle_fatal: make error message a bit more descriptive
 * Updated French translation.
 * Create pgp and s/mime default and sign_as key vars. (see neomutt#3983)
 * Add missing setup calls when resuming encrypted drafts.
 * mutt_pretty_size: show real number for small files
 * examine_directory: set directory/symlink size to zero
 * Update pl.po
 * Fixed GPGME translations that weren’t shown but affected the keyboard
 * docs: update encrypt-to-self
 * Update smime.rc: Typo fix, consistent headings
 * Add pgp_default_key and smime_sign_as info to contrib rc files.
 * Split Copyright and Thanks in help output.
 * strip out copyright translations
  • Loading branch information
flatcap committed Jan 16, 2018
2 parents 5820043 + 6fc83eb commit c70938e
Show file tree
Hide file tree
Showing 51 changed files with 355 additions and 680 deletions.
5 changes: 4 additions & 1 deletion browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,10 @@ static int examine_directory(struct Menu *menu, struct BrowserState *state,
if (lstat(buffer, &s) == -1)
continue;

if ((!S_ISREG(s.st_mode)) && (!S_ISDIR(s.st_mode)) && (!S_ISLNK(s.st_mode)))
/* No size for directories or symlinks */
if (S_ISDIR(s.st_mode) || S_ISLNK(s.st_mode))
s.st_size = 0;
else if (!S_ISREG(s.st_mode))
continue;

tmp = Incoming;
Expand Down
2 changes: 1 addition & 1 deletion compose.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static void redraw_crypt_lines(struct Header *msg)
SETCOLOR(MT_COLOR_COMPOSE_HEADER);
printw("%*s", HeaderPadding[HDR_CRYPTINFO], _(Prompts[HDR_CRYPTINFO]));
NORMAL_COLOR;
printw("%s", SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
printw("%s", SmimeSignAs ? SmimeSignAs : _("<default>"));
}

if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME) &&
Expand Down
27 changes: 25 additions & 2 deletions contrib/gpg.rc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# the "loopback" argument in instances where "--passphrase-fd" is
# used.
#
# The gpg-2comp found in some comments comes from
# Some of the older commented-out versions of the commands use gpg-2comp from:
# http://70t.de/download/gpg-2comp.tar.gz
#
# %p The empty string when no passphrase is needed,
Expand All @@ -24,12 +24,35 @@
# file's name.
#
# %a In "signing" contexts, this expands to the value of the
# configuration variable $pgp_sign_as. You probably need to
# configuration variable $pgp_sign_as, if set, otherwise
# $pgp_default_key. You probably need to
# use this within a conditional % sequence.
#
# %r In many contexts, neomutt passes key IDs to pgp. %r expands to
# a list of key IDs.

# Section A: Key Management

# The default key for encryption (used by $pgp_self_encrypt and
# $postpone_encrypt).
#
# It will also be used for signing unless $pgp_sign_as is set to a
# key.
#
# Unless your key does not have encryption capability, uncomment this
# line and replace the keyid with your own.
#
# set pgp_default_key="0x12345678"

# If you have a separate signing key, or your key _only_ has signing
# capability, uncomment this line and replace the keyid with your
# signing keyid.
#
# set pgp_sign_as="0x87654321"


# Section B: Commands

# Note that we explicitly set the comment armor header since GnuPG, when used
# in some localiaztion environments, generates 8bit data in that header, thereby
# breaking PGP/MIME.
Expand Down
27 changes: 22 additions & 5 deletions contrib/smime.rc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,28 @@ set crypt_replysign = yes
set crypt_replysignencrypted = yes
set crypt_verify_sig = yes

# Section A: Key Management.

# The (default) keyfile for signing/decrypting. Uncomment the following
# Section A: Key Management

# The default keyfile for encryption (used by $smime_self_encrypt and
# $postpone_encrypt).
#
# It will also be used for decryption unless
# $smime_decrypt_use_default_key is unset.
#
# It will additionally be used for signing unless $smime_sign_as is
# set to a key.
#
# Unless your key does not have encryption capability, uncomment this
# line and replace the keyid with your own.
set smime_default_key="12345678.0"
#
# set smime_default_key="12345678.0"

# If you have a separate signing key, or your key _only_ has signing
# capability, uncomment this line and replace the keyid with your
# signing keyid.
#
# set smime_sign_as="87654321.0"

# Uncomment to make neomutt ask what key to use when trying to decrypt a message.
# It will use the default key above (if that was set) else.
Expand Down Expand Up @@ -56,7 +73,7 @@ set smime_import_cert_command="/usr/lib/neomutt/smime_keys add_cert %f"



# Sction B: Outgoing messages
# Section B: Outgoing messages

# Algorithm to use for encryption.
# valid choices are aes128, aes192, aes256, rc2-40, rc2-64, rc2-128, des, des3
Expand All @@ -74,7 +91,7 @@ set smime_sign_command="openssl smime -sign -md %d -signer %c -inkey %k -passin



#Section C: Incoming messages
# Section C: Incoming messages

# Decrypt a message. Output is a MIME entity.
set smime_decrypt_command="openssl smime -decrypt -passin stdin -inform DER -in %f -inkey %k -recip %c"
Expand Down
59 changes: 39 additions & 20 deletions doc/manual.xml.head
Original file line number Diff line number Diff line change
Expand Up @@ -2707,11 +2707,11 @@ color sidebar_divider color8 default
message will be encrypted using the selected public keys when sent
out.</para>
<para>
To ensure you can view encrypted message you have sent, you
To ensure you can view encrypted messages you have sent, you
may wish to set <link linkend="pgp-self-encrypt">$pgp_self_encrypt</link>
and <link linkend="pgp-self-encrypt-as">$pgp_self_encrypt_as</link> for PGP, or
and <link linkend="pgp-default-key">$pgp_default_key</link> for PGP, or
<link linkend="smime-self-encrypt">$smime_self_encrypt</link>
and <link linkend="smime-self-encrypt-as">$smime_self_encrypt_as</link> for S/MIME.
and <link linkend="smime-default-key">$smime_default_key</link> for S/MIME.
</para>
<para>Most fields of the entries in the key selection menu (see also
<link linkend="pgp-entry-format">$pgp_entry_format</link>) have obvious
Expand Down Expand Up @@ -10520,20 +10520,23 @@ set index_format='%4C %Z %&lt;[y?%&lt;[m?%&lt;[d?%[%H:%M ]&amp;%[%a %d]&gt;&amp;
<link linkend="fcc-clear">$fcc_clear</link>.</para>
<para>A better option is to enable
<link linkend="smime-self-encrypt">$smime_self_encrypt</link>, then set
<link linkend="smime-self-encrypt-as">$smime_self_encrypt_as</link> to your
<link linkend="smime-default-key">$smime_default_key</link> to your
personal S/MIME key id.</para>
<screen>
set smime_self_encrypt = yes
set smime_self_encrypt_as = bb345e23.0
set smime_self_encrypt = yes
set smime_default_key = bb345e23.0
</screen>
<para>Or, if you use PGP,
<link linkend="pgp-self-encrypt">$pgp_self_encrypt</link>, then set
<link linkend="pgp-self-encrypt-as">$pgp_self_encrypt_as</link> to your personal PGP key
id.</para>
<link linkend="pgp-default-key">$pgp_default_key</link> to your personal
PGP key id.</para>
<screen>
set pgp_self_encrypt = yes
set pgp_self_encrypt_as = A4AF18C5582473BD35A1E9CE78BB3D480042198E
set pgp_self_encrypt = yes
set pgp_default_key = A4AF18C5582473BD35A1E9CE78BB3D480042198E
</screen>
<para>If you have different key for signing, then you can set
<link linkend="pgp-sign-as">$pgp_sign_as</link> or
<link linkend="smime-sign-as">$smime_sign_as</link> respectively.</para>
</sect2>

<sect2 id="encrypt-to-self-variables">
Expand All @@ -10552,28 +10555,42 @@ set pgp_self_encrypt_as = A4AF18C5582473BD35A1E9CE78BB3D480042198E
<tbody>
<row>
<entry>
<literal>smime_self_encrypt</literal>
<literal>pgp_default_key</literal>
</entry>
<entry>string</entry>
<entry>(empty)</entry>
</row>
<row>
<entry>
<literal>pgp_self_encrypt</literal>
</entry>
<entry>boolean</entry>
<entry><literal>no</literal></entry>
<entry><literal>yes</literal></entry>
</row>
<row>
<entry>
<literal>smime_self_encrypt_as</literal>
<literal>pgp_sign_as</literal>
</entry>
<entry>string</entry>
<entry>(empty)</entry>
</row>
<row>
<entry>
<literal>pgp_self_encrypt</literal>
<literal>smime_default_key</literal>
</entry>
<entry>string</entry>
<entry>(empty)</entry>
</row>
<row>
<entry>
<literal>smime_self_encrypt</literal>
</entry>
<entry>boolean</entry>
<entry><literal>no</literal></entry>
<entry><literal>yes</literal></entry>
</row>
<row>
<entry>
<literal>pgp_self_encrypt_as</literal>
<literal>smime_sign_as</literal>
</entry>
<entry>string</entry>
<entry>(empty)</entry>
Expand All @@ -10592,12 +10609,14 @@ set pgp_self_encrypt_as = A4AF18C5582473BD35A1E9CE78BB3D480042198E
# VARIABLES - shown with their default values
# --------------------------------------------------------------------------
# Save a copy of outgoing email, encrypted to yourself</emphasis>
set smime_self_encrypt = "no"
<emphasis role="comment"># set smime_self_encrypt_as = "SMIME-KEY"
set pgp_self_encrypt = "yes"
set pgp_default_key = "PGP-KEY"
<emphasis role="comment"># set pgp_sign_as = "PGP-SIGNING-KEY"

# Save a copy of outgoing email, encrypted to yourself</emphasis>
set pgp_self_encrypt = "no"
<emphasis role="comment">set pgp_self_encrypt_as = "PGP-KEY"
set smime_self_encrypt = "yes"
set smime_default_key = "SMIME-KEY"
<emphasis role="comment"># set smime_sign_as = "SMIME-SIGNING-KEY"

# vim: syntax=neomuttrc</emphasis>
</screen>
Expand Down
4 changes: 2 additions & 2 deletions globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ WHERE short ImapPollTimeout;
/* -- formerly in pgp.h -- */
WHERE struct Regex *PgpGoodSign;
WHERE struct Regex *PgpDecryptionOkay;
WHERE char *PgpDefaultKey;
WHERE char *PgpSignAs;
WHERE short PgpTimeout;
WHERE char *PgpEntryFormat;
Expand All @@ -298,10 +299,10 @@ WHERE char *PgpVerifyKeyCommand;
WHERE char *PgpListSecringCommand;
WHERE char *PgpListPubringCommand;
WHERE char *PgpGetkeysCommand;
WHERE char *PgpSelfEncryptAs;

/* -- formerly in smime.h -- */
WHERE char *SmimeDefaultKey;
WHERE char *SmimeSignAs;
WHERE short SmimeTimeout;
WHERE char *SmimeCertificates;
WHERE char *SmimeKeys;
Expand All @@ -318,7 +319,6 @@ WHERE char *SmimePk7outCommand;
WHERE char *SmimeGetCertCommand;
WHERE char *SmimeImportCertCommand;
WHERE char *SmimeGetCertEmailCommand;
WHERE char *SmimeSelfEncryptAs;

#ifdef USE_NOTMUCH
WHERE int NmOpenTimeout;
Expand Down
44 changes: 29 additions & 15 deletions imap/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include "config.h"
#include <ctype.h>
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -167,7 +168,8 @@ static void cmd_handle_fatal(struct ImapData *idata)
{
mx_fastclose_mailbox(idata->ctx);
mutt_socket_close(idata->conn);
mutt_error(_("Mailbox closed"));
mutt_error(_("Mailbox %s@%s closed"), idata->conn->account.login,
idata->conn->account.host);
mutt_sleep(1);
idata->state = IMAP_DISCONNECTED;
}
Expand Down Expand Up @@ -253,8 +255,7 @@ static void cmd_parse_expunge(struct ImapData *idata, const char *s)

mutt_debug(2, "Handling EXPUNGE\n");

exp_msn = atoi(s);
if (exp_msn < 1 || exp_msn > idata->max_msn)
if (mutt_atoui(s, &exp_msn) < 0 || exp_msn < 1 || exp_msn > idata->max_msn)
return;

h = idata->msn_index[exp_msn - 1];
Expand Down Expand Up @@ -299,8 +300,7 @@ static void cmd_parse_fetch(struct ImapData *idata, char *s)

mutt_debug(3, "Handling FETCH\n");

msn = atoi(s);
if (msn < 1 || msn > idata->max_msn)
if (mutt_atoui(s, &msn) < 0 || msn < 1 || msn > idata->max_msn)
{
mutt_debug(3, "#1 FETCH response ignored for this message\n");
return;
Expand All @@ -313,7 +313,7 @@ static void cmd_parse_fetch(struct ImapData *idata, char *s)
return;
}

mutt_debug(2, "Message UID %d updated\n", HEADER_DATA(h)->uid);
mutt_debug(2, "Message UID %u updated\n", HEADER_DATA(h)->uid);
/* skip FETCH */
s = imap_next_word(s);
s = imap_next_word(s);
Expand Down Expand Up @@ -346,7 +346,11 @@ static void cmd_parse_fetch(struct ImapData *idata, char *s)
{
s += 3;
SKIPWS(s);
uid = (unsigned int) atoi(s);
if (mutt_atoui(s, &uid) < 0)
{
mutt_debug(2, "Illegal UID. Skipping update.\n");
return;
}
if (uid != HEADER_DATA(h)->uid)
{
mutt_debug(2, "FETCH UID vs MSN mismatch. Skipping update.\n");
Expand Down Expand Up @@ -409,7 +413,7 @@ static void cmd_parse_list(struct ImapData *idata, char *s)
struct ImapList *list = NULL;
struct ImapList lb;
char delimbuf[5]; /* worst case: "\\"\0 */
long litlen;
unsigned int litlen;

if (idata->cmddata && idata->cmdtype == IMAP_CT_LIST)
list = (struct ImapList *) idata->cmddata;
Expand Down Expand Up @@ -610,7 +614,8 @@ static void cmd_parse_search(struct ImapData *idata, const char *s)

while ((s = imap_next_word((char *) s)) && *s != '\0')
{
uid = (unsigned int) atoi(s);
if (mutt_atoui(s, &uid) < 0)
continue;
h = (struct Header *) mutt_hash_int_find(idata->uid_hash, uid);
if (h)
h->matched = true;
Expand All @@ -631,10 +636,11 @@ static void cmd_parse_status(struct ImapData *idata, char *s)
char *value = NULL;
struct Buffy *inc = NULL;
struct ImapMbox mx;
int count;
unsigned long ulcount;
unsigned int count;
struct ImapStatus *status = NULL;
unsigned int olduv, oldun;
long litlen;
unsigned int litlen;
short new = 0;
short new_msg_count = 0;

Expand Down Expand Up @@ -673,7 +679,15 @@ static void cmd_parse_status(struct ImapData *idata, char *s)
while (*s && *s != ')')
{
value = imap_next_word(s);
count = strtol(value, &value, 10);

errno = 0;
ulcount = strtoul(value, &value, 10);
if (((errno == ERANGE) && (ulcount == ULONG_MAX)) || ((unsigned int) ulcount != ulcount))
{
mutt_debug(1, "Error parsing STATUS number\n");
return;
}
count = (unsigned int) ulcount;

if (mutt_str_strncmp("MESSAGES", s, 8) == 0)
{
Expand All @@ -695,7 +709,7 @@ static void cmd_parse_status(struct ImapData *idata, char *s)
}
mutt_debug(
3,
"%s (UIDVALIDITY: %d, UIDNEXT: %d) %d messages, %d recent, %d unseen\n",
"%s (UIDVALIDITY: %u, UIDNEXT: %u) %d messages, %d recent, %d unseen\n",
status->name, status->uidvalidity, status->uidnext, status->messages,
status->recent, status->unseen);

Expand Down Expand Up @@ -733,7 +747,7 @@ static void cmd_parse_status(struct ImapData *idata, char *s)

if (value && (imap_mxcmp(mailbox, value) == 0))
{
mutt_debug(3, "Found %s in buffy list (OV: %d ON: %d U: %d)\n", mailbox,
mutt_debug(3, "Found %s in buffy list (OV: %u ON: %u U: %d)\n", mailbox,
olduv, oldun, status->unseen);

if (MailCheckRecent)
Expand Down Expand Up @@ -827,7 +841,7 @@ static int cmd_handle_untagged(struct ImapData *idata)
mutt_debug(2, "Handling EXISTS\n");

/* new mail arrived */
count = atoi(pn);
mutt_atoui(pn, &count);

if (!(idata->reopen & IMAP_EXPUNGE_PENDING) && count < idata->max_msn)
{
Expand Down
Loading

0 comments on commit c70938e

Please sign in to comment.