Ralph Corderoy [Wed, 24 Jan 2018 00:27:01 +0000 (00:27 +0000)]
%(divide): Avoid SIGFPE on integer divide of INT_MIN by -1.
Dividing by zero isn't the only cause of SIGFPE.
fmttest -raw -format '%(num -2147483648) %(divide -1)' foo
Also, add FIXME comment suggesting the user should be told of overflow
rather than silently using zero as the result.
Ralph Corderoy [Wed, 24 Jan 2018 00:12:59 +0000 (00:12 +0000)]
Use trim_suffix_c() to remove optional trailing character.
I'm unsure if one of the cases can know the string's length is long
enough to read the char before the NUL. Using trim_suffix_c()
simplifies and removes the possibility.
Ralph Corderoy [Wed, 24 Jan 2018 13:49:06 +0000 (13:49 +0000)]
mhfixmsg.man: Replace UTF-8 `§' with `\(sc' troff escape.
man page source is ASCII. GNU groff's troff's source is ISO 8859-1.
The `§' in UTF-8 looks like `§' in ISO 8859-1. If those two bytes make
it to a UTF-8 terminal then it appears as `§', but target something
else, e.g. PDF, and the flaw shows.
Also adjust test-manpages to grep for bytes other than HT, and SPACE to
tilde, in the built man pages. A test of the source could be also be
done for the Makefile's `all' target, but this one should remain to spot
the build process breaking things, e.g. non-ASCII in $prefix.
Ralph Corderoy [Tue, 23 Jan 2018 16:37:01 +0000 (16:37 +0000)]
fmt_scan(): Avoid undefined behaviour from overlapping strncpy(3).
M. Levinson pointed out in private email that pcc(1) tickles a bug that
causes undefined behaviour due to part of `buffer[]', accessed by `str',
being strncpy(3) back to its start. Fix by using memmove(3) to slide
`str' back to `buffer's beginning whenever it may have wandered off.
Fixes e8635a8a that added `%(unquote)', but using `%(trim)' twice was
also faulty in the same way and pre-dates git.
Ralph Corderoy [Tue, 23 Jan 2018 09:18:34 +0000 (09:18 +0000)]
mhshow: Avoid SEGV when user's command has two or fewer words.
After argsplit() returned a NULL-terminated vector, the existing NULL
was overwritten with another and the vector index then incremented.
This made the test for whether vec[2] was available out by one resulting
in NULL being used and printed.
This plucking of the third word is a faulty assumption as argsplit()
doesn't always return ["sh", "-c", ...], but add a new test script for
it to avoid regression and so that the script can be expanded with more
related tests.
Debian's packager, Alexander Zanger, reported test/oauth/test-* problems
due to environment variables for the system's network proxies. David
Levine suggested the unsetting of them. The tests only make HTTP
connections so just the variables affecting those are unset.
Ken Hornstein [Sun, 10 Dec 2017 05:36:21 +0000 (00:36 -0500)]
Add support for setting nmh directories.
Add new precious variables (nmhlibexecdir and nmhetcdir) that will
permit the user to specify these directories exactly. They default to
$(libexecdir)/nmh and $(sysconfdir)/nmh, respectively.
Ralph Corderoy [Mon, 27 Nov 2017 15:20:44 +0000 (15:20 +0000)]
test-mhfixmsg: pwd(1)'s `-P' needed to avoid failure with symlinks.
Steven Winikoff reported to nmh-workers that one of this file's tests
failed in 1.7. It attempts to manipulate the output of mhpath(1)
assuming it starts with the result of `pwd', but symlinks in the latter
may cause this to fail. Use POSIX's `-P' option to ensure no symlinks,
as done in some other tests.
David Levine [Sun, 26 Nov 2017 22:27:48 +0000 (17:27 -0500)]
Use ISO-2022-KR instead of EBCDIC-US in test-charset, because
Robert Elz reported that it is installed on his NetBSD host.
Also, don't run that check without iconv.
Ralph Corderoy [Sun, 26 Nov 2017 12:09:22 +0000 (12:09 +0000)]
Fix tests that assume the backup prefix is a comma.
Steven Winikoff reported to nmh-workers that some tests failed in 1.7
configured with --with-hash-backup because they assume the backup prefix
is comma rather than hash. Alter those tests to use `mhparam sbackup',
as other tests already do. PATH is already set to use the mhparam being
tested.
test-mhfixmsg used find(1) to check for leftover files that globbed
`mhfix*' or `,mhfix*'. Changed to just `*mhfix*' as I think any file
containing that would be unwanted, and it will also spot mhfixmsg
hard-coding the comma prefix.
David Levine [Fri, 24 Nov 2017 23:41:23 +0000 (18:41 -0500)]
Reworked parameter value tests to reflect Ralph's (re-?) discovery
that GNU iconv elides the ? from charset names. nmh uses it as a
replacement character when decoding fails.
Ralph Corderoy [Wed, 22 Nov 2017 13:44:01 +0000 (13:44 +0000)]
Rewrite cpnumber() to fix `%2(msg)' with 123 overflowing to `?23'.
Reported in 1.7 by Ken on nmh-workers yesterday.
`It seems this was introduced in commit 92128dacf'.
We now use the C library to format the number, and then manipulate the
result. A temporary charstring_t is no longer used.
Also adds left justification using negative width.
Ralph Corderoy [Wed, 15 Nov 2017 23:29:04 +0000 (23:29 +0000)]
crawl_folders.h: Base header on implementation.
Normally done as part of extracting the new header file from a larger
one, but this file already existed so it had to be moved as one commit
and altered in the next, otherwise git would break its history.
Ralph Corderoy [Tue, 14 Nov 2017 23:56:16 +0000 (23:56 +0000)]
h/rcvmail.h: Delete. Contained just a couple of pointless macros.
RCV_MOK was 0, RCV_MBX was 1. They were used for exit(3) and done().
`exit(0)' is clearer than another layer of abstraction, and the commands
that used them didn't seem to document the exit statuses anyway. The
included by other means, at least on one platform.
Ralph Corderoy [Tue, 14 Nov 2017 23:41:18 +0000 (23:41 +0000)]
popsbr.h: Base header on implementation.
Normally done as part of extracting the new header file from a larger
one, but this file already existed so it had to be moved as one commit
and altered in the next, otherwise git would break its history.