Ken Hornstein [Sat, 4 Nov 2017 13:59:18 +0000 (09:59 -0400)]
Use va_copy() to get a copy of va_list, instead of using original.
netsec_vprintf() can call vsnprintf() twice if the outgoing buffer is
full (but it happens rarely in practice, given the way the current
code uses it). But if this DOES happen, vsnprintf() will use the
same va_list argument twice, and the second time around either it will
grab a random bit of memory off of the stack OR it will segfault.
So we always use va_copy() to get our own copy of the passed-in va_list
and work on that.
Ralph Corderoy [Thu, 2 Nov 2017 01:46:26 +0000 (01:46 +0000)]
md5.c, md5.h: Reformat and delete needless portability.
The algorithm is not going to change, bugs are unlikely to appear in the
upstream RSA version, so reformat the source to be more readable, and
delete portability code now we have function prototypes with parameters,
void pointer, etc.
Ralph Corderoy [Thu, 2 Nov 2017 00:34:18 +0000 (00:34 +0000)]
repl.c, replsbr.c: Move shared data into header file.
repl.c declared global variables, and replsbr.c had extern statements
that hopefully matched them. But they're really inputs into replsbr.c's
code, so move the declarations into a new header file that both then
include, and define them in replsbr.c.
Ralph Corderoy [Wed, 1 Nov 2017 11:39:37 +0000 (11:39 +0000)]
send.c, whatnowsbr.c: Delete option variables set but never read.
Some options are passed on without the code parsing the options having
to act upon their value. These don't need to store the option's Boolean
value in a local variable that's never read.
Ralph Corderoy [Mon, 30 Oct 2017 20:29:29 +0000 (20:29 +0000)]
Replace adios(NULL, ...) with die(...).
It's the common case, and saves having to skip over the NULL when
reading, and avoids the risk of the format string being passed as the
first parameter by mistake.
Ralph Corderoy [Mon, 30 Oct 2017 19:52:11 +0000 (19:52 +0000)]
mhbuild.man: Avoid using format-free printf(3) in example.
It pops up in searches for printf()s that could be fputs(),
and as printf() it doesn't output the trailing `\n' to end the line.
Replace with puts(). Lowercase Kernighan's message, as he wrote it.
Ralph Corderoy [Sat, 28 Oct 2017 22:04:54 +0000 (23:04 +0100)]
msgchk.c: Rewrite checkmail(), removing need for macros.
NONEOK, MMDFOLD, etc., were only used to track simple Boolean
conditions. Rewriting the function removes the need for them, and gives
shorter, more clear, code. The macros pre-date git's history.
Ralph Corderoy [Sat, 28 Oct 2017 12:57:00 +0000 (13:57 +0100)]
whatnow: Remove undocumented printf-formatting of -prompt string.
whatnow(1)'s -prompt option would use the value as a printf(3) format
string, supplying `invo_name' as the sole value to be formatted. This
was undocumented, and upset gcc's checking of format strings. As no
requests to keep the ability appeared on nmh-workers in reply to
2017-08-09's email, treat -prompt's value as a simple string.
Ralph Corderoy [Sat, 28 Oct 2017 11:38:05 +0000 (12:38 +0100)]
SPECS: Alter description to not require a GUI interface.
xmh or exmh are optional, not required to use nmh. Mention them both,
but remove the dependency on whether either is available as a package.
Add possible search terms, e.g. `MIME' and `shell'.
Ralph Corderoy [Fri, 27 Oct 2017 11:28:28 +0000 (12:28 +0100)]
configure.ac: Test for libtinfo to resolve setupterm(3).
ncurses 6.0+20170902-2 on Arch Linux doesn't provide setupterm(); it
did in earlier versions. This stops ./configure finding a suitable
library. Add tinfo to the search list, as that's the lower-level
library that contains setupterm() now, and place it before curses and
ncurses so the search stops if it's sufficient instead of the larger
libraries.
Ralph Corderoy [Tue, 26 Sep 2017 20:14:06 +0000 (21:14 +0100)]
msgchk.c: Remove UUCP tests; unused since `#ifdef MF'.
The values UUCPOLD et al are never set so don't bother testing for them.
They haven't be possible in git's history. They were guarded in the
past by `#ifdef MF'; that stood for `mail filter'.
Ralph Corderoy [Fri, 27 Oct 2017 12:44:26 +0000 (13:44 +0100)]
imaptest.c: Don't test possibly uninitialised local variable.
get_imap_response() doesn't necessarily set the content of a non-NULL
`char **status'. Do this before calling, and check if it's been set to
non-NULL before using upon return.
Ken Hornstein [Wed, 25 Oct 2017 03:16:31 +0000 (23:16 -0400)]
Rototill snoop support so it works at flush time.
Before on writes, the output snoop support would only work when it was
doing netsec_vprintf(). Do it at flush time, so it should work for
any type of write.
Ken Hornstein [Tue, 24 Oct 2017 18:47:19 +0000 (14:47 -0400)]
Add context information to SASL callback.
Provide an extra context argument for the SASL negotiation callback
that application code can use to pass down information that the
callback might need.
Ralph Corderoy [Sun, 24 Sep 2017 13:26:02 +0000 (14:26 +0100)]
inc/test-eom-align: Create test mboxes in less steps.
Use a couple of temporary files created at the beginning to allow runs
of alternating cat(1) and echo(1) to be a single cat. Knocks 15% off
the `make check' time for that single test in a simple trial here.
Also, have the email body end in what appears to be the MMDF magic
string for the first few bytes; otherwise, the test mbox is just a
boring single email compared to the `A', From_, version. Fixes 8699f1cc.
The `...LINESZ' variables are number of bytes, not number of lines, so
MMDF's is now 5 rather than 1. And the MMDF magic string tops and tails
each email so needs to be subtracted twice, not once like From_'s.
Fixes 8699f1cc.
Ralph Corderoy [Sat, 23 Sep 2017 21:27:46 +0000 (22:27 +0100)]
Stop failed m_mktemp2() that give directory reporting get_temp_dir().
The first parameter of m_mktemp2(), if not NULL, is a path and the
basename is used as the directory to hold the new temporary file, but
the error message on failing to create that used get_temp_dir() and
that's often somewhere else, e.g. `mhbuild /dev/null' attempts /dev/...
Don't attempt to state the failed path in the error message as at least
that's not misleading. Perhaps the function needs some other indication
of success so it can pass back the attempted filename that failed.
Ralph Corderoy [Sat, 23 Sep 2017 17:16:26 +0000 (18:16 +0100)]
mhbuild.c: Don't use set_done() to unlink temporary files.
Because they're created with m_mktemp2(), the temporary files are
already in a list to be unlink(2)'d at exit(3), thanks to atexit(3), so
don't set_done() to attempt that twice. Updates 6bc64765f.
Ralph Corderoy [Sat, 23 Sep 2017 13:29:38 +0000 (14:29 +0100)]
mhshow/test-charset: Test iconv(1)'s result, not just its exit status.
Problems with generating the input to iconv(1) were hidden as long as it
could be converted from EBCDIC-US to UTF-8 because only the exit status
was tested. Check the output is as expected too.
Ralph Corderoy [Sat, 23 Sep 2017 13:14:12 +0000 (14:14 +0100)]
mhshow/test-charset: printf(1)'s octal doesn't need a leading zero.
The `\0344' was being interpreted as `\034' and `4'. This can still be
converted from EBCDIC-US to UTF-8 by iconv(1) so the test worked, but it
was misleading. Remove the leading zero as printf's octal escape is
`\nnn' where nnn is one to three octal digits. It's echo(1) that
insists on a leading zero. Fixes 6fd1d18f.
Ralph Corderoy [Thu, 21 Sep 2017 15:59:15 +0000 (16:59 +0100)]
Detect function-pointer `done' being set twice in a row.
Make `done' a function that uses a file-static function pointer, and add
set_done() to alter it. That wants either the old or new value to be
exit(3). If it's not, it still alters the stored pointer, to maintain
the existing behaviour, but emits a warning on stderr. mhbuild(1)
triggers that warning, making this hunch worthwhile.
Ralph Corderoy [Mon, 18 Sep 2017 22:29:24 +0000 (23:29 +0100)]
sendfiles: Always die with exit status of 1 rather than -1.
The sh function die() took the exit status as an optional parameter,
with a default of -1, but this was never used so remove the option and
always use an exit status of 1.
Ralph Corderoy [Mon, 18 Sep 2017 14:28:26 +0000 (15:28 +0100)]
Remove preprocessor conditionals on `lint'.
Treat all tests for `lint' being defined as false. Don't know when
anyone had a lint(1) that could be run on the source, but none of the
areas had been touched in git's history, and at least one would have
been a compile error had it been defined.
Ralph Corderoy [Mon, 18 Sep 2017 11:43:28 +0000 (12:43 +0100)]
whom.c: Don't call rename(2) with source that's uninitialised.
The intent is that two rename(2)s take place: to move a file to a
backup and then return it. The first test controlled the generation of
the destination in the char array `backup' and calling the first
rename(). The second test used that same array for the restoring
rename(), but used a different test and so could run when the first
rename hadn't, and with an uninitialised array for the source filename.
The initialisation of `backup' and the first rename needed both
environment variables `mhdist' and `mhaltmsg' to be non-empty, and the
former to have a non-zero atoi(3) value. The second rename ignored
`mhaltmsg'. Bug pre-dates git.