Ken Hornstein [Tue, 23 Apr 2019 01:42:14 +0000 (21:42 -0400)]
Set the close-on-exec flag for sockets
Since we no longer use closefds(), start cleaning up stray descriptors.
Start by making sure that any network sockets we create have the
close-on-exec flag set on them.
Ken Hornstein [Tue, 23 Apr 2019 00:36:14 +0000 (20:36 -0400)]
Garbage collect closefds()
Remove the closefds() function; it was used sporadically and was
causing problems on High Sierra. In the future look at opening
more descriptors with FD_CLOEXEC.
Ken Hornstein [Fri, 22 Mar 2019 15:59:04 +0000 (11:59 -0400)]
Add support for %(trimr) format function
Add support for a %(trimr) format function, which behaves exactly
like %(trim) but also returns a string. Turns out this is literally
a one-line change that does not require a new format instruction.
David Levine [Sat, 10 Nov 2018 17:35:31 +0000 (12:35 -0500)]
Added -attendee switch to mhical(1).
This allows the user to select which of their attendee addresses they are
responding about, when they have more than one in the invitation.
Added corresponding -a switch to calaccept, etc., functions in replaliases.
Updated mhical to retain DESCRIPTION lines. Gmail puts a link to the event
DESCRIPTION line along with a message to no edit that section, though it
seems to accept responses if the DESCRIPTION line was removed.
Incremented mhical version number to 0.5.
David Levine [Thu, 1 Nov 2018 23:44:32 +0000 (19:44 -0400)]
Increased sizes of a couple of buffers.
gcc 8 noticed that snprintf could have overrun them. It might be
better to reduce the sizes of buffers used for display names, etc.
Or ever better, use dynamically sized buffers.
Ralph Corderoy [Sun, 1 Jul 2018 08:43:05 +0000 (09:43 +0100)]
mhlsbr.c: Use variable for strncpy(3)'s size, not sizeof.
Silences gcc 8.1.1's warning that the size of the source was being used,
not the destination. The destination has just been allocated to be the
size of the source so no overflow can occur. Move existing variable
that later holds the buffer size to before the allocation and strncpy so
it can be used for those too.
Ralph Corderoy [Sun, 1 Jul 2018 08:32:28 +0000 (09:32 +0100)]
rcvtty.c: Use struct utmpx's ut_line[], not a copy.
Silences gcc 8.1.1's warning that strncpy(3)'s length is the sizeof of
the source, not the destination, by removing the strncpy and passing the
source to alert() where it's only read, not written.
David Levine [Tue, 20 Feb 2018 02:30:17 +0000 (21:30 -0500)]
Fixed mhshow/test-charset to work on all tested platforms.
Restores the functionality of commit f81046da6. Also, skips the
last two tests if iconv isn't enabled. And removes the test
files if the last test, without iconv_elides_question_marks, behaves
as expected. Finally, some comments have been updated.
Ken Hornstein [Mon, 12 Feb 2018 21:01:08 +0000 (16:01 -0500)]
Avoid free() in format engine for now.
This free() call messes up the buffer handling in scansbr.c:scan();
for now we're going to live with the leak and fix this properly when
we normalize the format engine's memory handling.
Ralph Corderoy [Sun, 11 Feb 2018 13:02:24 +0000 (13:02 +0000)]
cpstripped(): Replace malloc()s with statics based on MB_LEN_MAX.
MB_CUR_MAX from stdlib.h isn't a compile-time constant so can't be used
for the size of a couple of static char arrays so malloc() was used at
run time, with the tiny claims never being freed. valgrind(1) noticed
and David suggested MB_LEN_MAX from limits.h instead; that header's
contents are suitable for #if expressions and thus compile-time
constants.
Ken Hornstein [Sat, 10 Feb 2018 04:15:32 +0000 (23:15 -0500)]
Clean up memory leaks by callers of scan().
Make sure we reuse the "scanl" argument to the scan() function, as that's
the signal to have scan() reuse it's buffers. Otherwise repeated calls
to scan will leak a TON of memory. Reported by Ralph Corderoy.
David Levine [Fri, 9 Feb 2018 00:43:56 +0000 (19:43 -0500)]
Compile the header format for each message.
Per Ken's suggestion, compile_header() and compile_marker() are now
called for each message. That's done with reset_comptable disabled.
So, per Ralph's suggestion, fmt_free(NULL, 1) is called after all
messages are shown to free up memory held by the component table.
Ralph Corderoy [Sat, 3 Feb 2018 10:49:40 +0000 (10:49 +0000)]
test-charset: Fix test when HAVE_ICONV is false.
When the Content-Type's charset parameter's encoding is `invalid', it
makes no difference whether HAVE_ICONV is defined or not as the
parameter's value can't be decoded.
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.