Kevin McCarthy [Sat, 6 Jan 2018 23:55:17 +0000 (15:55 -0800)]
Change imap literal counts to parse and store unsigned ints.
IMAP literals are of type number. Change imap_get_literal_count() to
use mutt_atoui() instead of atoi(). Change the return type variables
used to store the count to type unsigned int.
It's doubtful this was a real issue, but as long as we're cleaning up
incorrect atoi() usage, we should fix this too.
Kevin McCarthy [Sat, 6 Jan 2018 04:39:50 +0000 (20:39 -0800)]
Fix improper signed int conversion of IMAP uid and msn values.
Several places in the imap code, when parsing "number" and "nz-number"
values from the IMAP data, use atoi() and strtol(). This is
incorrect, and can result in failures when a uid value happens to be
larger than 2^31.
Create a helper function, mutt_atoui() and use that instead. One
place was using strtol() and relying on the endptr parameter, and so
was changed to use strtoul() instead.
Thanks to Paul Saunders for the bug report and original patch, which
this commit is based on.
Kevin McCarthy [Sun, 31 Dec 2017 03:10:16 +0000 (19:10 -0800)]
Disable message security if the backend is not available.
Gitlab issue #3 exposed an awkward corner case: if mutt is configured
without PGP or S/MIME, and with GPGME, but $crypt_use_gpgme is unset.
In this case, no backend will be available, but WithCrypto will be set
with both APPLICATION_PGP and APPLICATION_SMIME bits.
That will allow various config vars to enable encryption or signing,
even though there will be no backend available to perform them. The
message security flag might then be set, but when the user hits send,
will end up back at the compose menu due to the error.
The pgp or smime menu might not even be available to clear the
security setting!
Add a check in send.c before the compose menu is invoked, and give a
warning message for the menu ops inside the compose menu.
I believe this should prevent the issue. However this is a corner
case combined with user misconfiguration, so I don't believe is worth
a large effort to completely eradicate.
Richard Russon [Thu, 28 Dec 2017 20:19:38 +0000 (20:19 +0000)]
merge: Prepare the code for the new config system
* regex obj to ptr
* refactor the hash types
* expand global bools,quadoptions
* Rename all the config bools OPT_ABC_XYZ -> AbcXyz
* Adjust the members of struct Options
* group the synonyms at the end of the list
* move all config variables to the end of the file
Aleksa Sarai [Sun, 17 Dec 2017 13:39:08 +0000 (00:39 +1100)]
nested-if: correctly handle "<" and ">" with %?
As part of the implementation of nested-if[1], we translate old-style
conditional expandos into nested-if expandos. However, this translation
did not account for the metacharacters that need to be escaped in
nested-if expandos that are valid in old-style expandos (in particular
"<" and ">"). Correct this by escaping the relevant metacharacters.
With this patch, it is now possible to do something like
:set status_format=" %rMail%r >%?u? +%u >?"
Without causing an ">" to be included if %u is 0 (which used to be the
case).
Kevin McCarthy [Fri, 15 Dec 2017 20:09:42 +0000 (12:09 -0800)]
Fix s/mime certificate deletion bug
Commit c1bcf4ba exposed a bug in the s/mime encryption code. It was
errorneously calling unlink on the list of generated cert files to
use.
Prior to that commit, the list had an initial space, which apparently
made the unlink fail. After that commit, encrypting to a single
certificate would end up deleting the certificate.
Remove the calls to unlink the cert file. Add some missing cleanup if
the call to openssl fails.
Richard Russon [Thu, 28 Dec 2017 13:41:15 +0000 (13:41 +0000)]
merge: fix coverity defects
* identical code for different branches
* fix resource leaks
* Array compared against 0
* Pointer to local outside scope
* hdr can't be NULL
* remove unused values
* fix use of 'fallthrough' comments
Richard Russon [Thu, 28 Dec 2017 13:35:01 +0000 (13:35 +0000)]
merge: trivial code fixes
* split if's containing assignments
* drop unnecessary FGETCONV typedef
* add doxygen warnings
* pgppubring: fix signed and unsigned comparison
* fix sensitive flag for config variables
* remove unnecessary preprocessor symbol
* add some checks to buffer code
* move conditional includes after others
Jakub Wilk [Thu, 14 Dec 2017 15:23:38 +0000 (16:23 +0100)]
Fix type mismatch in mutt_progress_init()
Fixes the following GCC warning:
curs_lib.c: In function ‘mutt_progress_init’:
curs_lib.c:471:65: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘size_t {aka unsigned int}’ [-Wformat=]
snprintf(progress->sizestr, sizeof(progress->sizestr), "%ld", progress->size);
^
Jakub Wilk [Thu, 14 Dec 2017 15:22:37 +0000 (16:22 +0100)]
Fix type mismatch in mutt_pretty_size()
Fixes the following GCC warnings:
muttlib.c: In function ‘mutt_pretty_size’:
config.h:55:19: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘size_t {aka unsigned int}’ [-Wformat=]
#define OFF_T_FMT "%" PRId64
^
muttlib.c:614:22: note: in expansion of macro ‘OFF_T_FMT’
snprintf(s, len, OFF_T_FMT "K", (n + 51) / 1024);
^~~~~~~~~
config.h:55:19: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘size_t {aka unsigned int}’ [-Wformat=]
#define OFF_T_FMT "%" PRId64
^
muttlib.c:621:22: note: in expansion of macro ‘OFF_T_FMT’
snprintf(s, len, OFF_T_FMT "M", (n + 52428) / 1048576);
^~~~~~~~~
Justin Vasel [Wed, 29 Nov 2017 18:00:44 +0000 (13:00 -0500)]
Bring consistency among sizes
There are instances in the code that refer to lengths or sizes of strings and
buffers and the like, but they are not typed in a consistent manner. The purpose
of this commit is to provide some consistency to these scenarios by changing
their type from unsigned int, int, unsigned long, etc. to size_t.
In general, these situations were identified by globally searching the code
for patterns along the lines of:
(unsigned|unsigned int|int|long) (len|blen|olen|length|l|size)
and changing the type to size_t on a case-by-case basis.
The following situations were explicitly ignored:
- autosetup/jimsh0.c, because it appears to be third-party code
- inputs to function calls relating to ssl and sasl, because they don't take
size_t as inputs and recasting in the function call didn't seem worth the
increased messiness
- for loop indices, because in some cases unsigned indices can breed bugs
This commit takes care of most obvious cases. There may certainly be subtler
ones that were missed in this pass.
Justin Vasel [Thu, 30 Nov 2017 04:29:58 +0000 (23:29 -0500)]
Configure number of directory components displayed in sidebar
In cases of a complex maildir directory structures, one may want to hide the
highest `N` directories from display in the sidebar to keep things looking
clean and legible.
This commit introduces a new config parameter, `sidebar_component_depth`, which
takes a positive integer as its value.
For example, suppose I have the following directory structure:
```
Inbox
dir1/dir2
dir1/dir2/dir3/sushi
dir1/dir2/dir3/neomutt/developer
```
By setting `sidebar_component_depth=2` in one's rc file, the sidebar will
display these maildirs in the following way:
```
Inbox
dir2
dir3/sushi
dir3/neomutt/developer
```
As seen in this example, the two highest directories have been truncated from
each path except in the case when there are `<= N` subdirectories, in which
case the bottom-most directory is displayed.
This parameter has a default value of 0, which disables the feature.
A previously-existing option, `sidebar_short_path`, provides similar behavior,
but truncates all except the bottom-most directories. When that option is
enabled, `sidebar_component_depth` is ignored.
Update autosetup to commit b5a0e85d87a46d931ff1e4f8e5de8cd5307f93ba
- this makes it accept --enable-silent-rules and --disable-silent-rules
amongst other things, as requested in
https://github.com/msteveb/autosetup/issues/33
Debian tools and probably other tools too pass arguments like
--mandir=\${prefix}/share/man
to configure. The prefix survives the output into the Makefile,
therefore, we need to define prefix in the Makefile too.
Pietro Cerutti [Fri, 1 Dec 2017 15:49:15 +0000 (15:49 +0000)]
Support reading FQDN from mailname files
Currently, we support reading from /etc/mailname and /etc/mail/mailname.
Adding support for more files is trivial. Reading these files is only
done if NeoMutt was configured without the --with-domain option.