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.
Ralph Corderoy [Mon, 18 Sep 2017 11:12:58 +0000 (12:12 +0100)]
If fork(2) fails then die; don't fall through to execve(2).
It's already been agreed that failure to fork() is so rare these days
that multiple attempts aren't required. Nor should the code persevere
by calling execve() as if the fork had succeeded, else why bother to
fork? Instead, die.
Ralph Corderoy [Mon, 18 Sep 2017 10:59:37 +0000 (11:59 +0100)]
whom.c: Don't increment atoi(3)'s return value as it's already true.
atoi(3) has returned non-zero and distsw holds that value. Only the
truthness of distsw matters. Don't increment distsw, as if to show it's
been set, because that would turn the true -1 to false 0. Bug pre-dates
git.
Up to 8 KiB was read into a buffer and then strchr() used to test for a
linefeed. There was no guarantee the linefeed would be present, else
why test for it, nor that the buffer would contain a NUL to terminate
the search, either from the read bytes, or the bytes not trampled by
read(). Replace the two similar lumps of code with a new
linefeed_typed(). Bug pre-dates git.
Ralph Corderoy [Sat, 16 Sep 2017 21:58:11 +0000 (22:58 +0100)]
mhlsbr.c: Don't read(2) from fileno(3) of stdout.
Remove the assumption that file descriptor 1 is readable. It can be if
it, or where it was dup(2)'d from, was opened read/write, e.g. on
/dev/tty. But it can easily be arranged with shell re-direction that it
isn't, and then the read(2) fails. Pass 0, standard input's file
descriptor, instead. Don't use fileno(stdin) as I can't think of a need
to support that being non-zero, but its use makes the reader think it
might. Bug pre-dates git.
Ralph Corderoy [Wed, 13 Sep 2017 10:09:42 +0000 (11:09 +0100)]
Remove casts of NULL to a data pointer.
With a function prototype in place stating a parameter is a foo pointer,
where foo is data, not a function, then `NULL' suffices so the cast to
foo pointer is redundant. If the function parameter is retrieved with
va_arg(3) then the pointer passed must be the retrieved type, e.g.
concat()'s arguments are fetched as char pointer and so it should be
called as `concat("foo", (char *)0)'. Using NULL is incorrect, though
NULL could be used instead of 0 but still needs casting. However, the
source doesn't bother getting this right and just passes NULL in most
cases so make the few match. Most of those changed were passing NULL
cast to a void pointer.
Ralph Corderoy [Tue, 12 Sep 2017 14:02:41 +0000 (15:02 +0100)]
Hoick FENDNULL(key) out of the search loop.
`key' is a loop-invariant so can be tested for NULL once before the
loop. In one case, this also avoid passing NULL to printf(3) for "%s",
and means getcpy()s can be replaced with mh_xstrdup()s.
If a `credential-file' context was found, and started with a `/', then
the m_defs's n_field was returned, otherwise a newly allocated string.
The caller couldn't tell whether to free the result or not so memory was
leaked. Alter it to always freshly allocate the result. Fixes 803f25412.
Ralph Corderoy [Sun, 10 Sep 2017 17:12:38 +0000 (18:12 +0100)]
slocal.c: Alter trim() to return static array, not malloc(3).
The callers are immediately passing the return value to printf(3) for
"%s". There's only one call per printf(). None of the callers are
bothering to free(3) the existing return value. Return the address of
trim()'s char array, now static, instead. Leave trim() returning NULL
when passed NULL, even though that gives NULL to print(3) for "%s". It,
and slocal's other bugs, remain.
Ralph Corderoy [Sun, 10 Sep 2017 14:11:18 +0000 (15:11 +0100)]
find_cache(): Remove test that's always false.
The if-statement's condition is a conjunctive that tests `!writing' and
then, only if that's true, calls find_cache_aux() and tests `writing' in
determining the first argument; that must be false. Bug pre-dates git
history.
Ralph Corderoy [Sun, 10 Sep 2017 14:03:09 +0000 (15:03 +0100)]
readline(3) wrapper: Move free(3) of line to where it's reachable.
Every line returned by readline() has to be freed. The call to free()
was unreachable because all paths heading towards it veered off,
resulting in a memory leak. Move the free() to just after where the
line has been used for the last time. Fixes 3a85e0bc9.