Re: [Nmh-workers] mhical vs /dev/null (possible NULL pointer dereference)

2017-08-17 Thread David Levine
Leonardo wrote:

> I'll attach in this email a possible trivial patch that should fix
> this issue.

Indeed.  Thank you!  I added a test to your patch and applied it to
both master and the 1.7-release branch.  It looks like it missed
1.7RC2, but I agree that it should go into 1.7.

> Thank you for the attention and keep up the good work!

Thank you for your contributions!

David

___
Nmh-workers mailing list
Nmh-workers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/nmh-workers


[Nmh-workers] mhical vs /dev/null (possible NULL pointer dereference)

2017-08-17 Thread Leonardo Taccari
Hello to the entire nmh community!
Today I've finally received an email with an `.ics' and so I've
used the new `mhical'. After running it via `mhical' I've figured
out that it expected an ics file as input and after just pressing
^D I've found that mhical wasn't happy about an empty input.

To reproduce it:

 % ./mhical < /dev/null
 Segmentation fault (core dumped)
 Exit 139
 % gdb -core ./mhical.core ./mhical
 Reading symbols from ./mhical...done.
 [New process 1]
 Core was generated by `mhical'.
 Program terminated with signal SIGSEGV, Segmentation fault.
 #0  display (nfs=, clines=0x0, file=0x623a98 <__sF+152>) at 
uip/mhical.c:717
 717 if (clines->next) {
 (gdb) quit

I'll attach in this email a possible trivial patch that should fix
this issue.
I have verified that it applies cleanly both to latest git version and
1.7RC1 (IMHO it's a good idea to apply it for 1.7 too).


Thank you for the attention and keep up the good work!
Avoid a possible NULL pointer dereference when mhical does not receive any input
(e.g. calling it via `mhical < /dev/null').

--- uip/mhical.c.orig	2017-08-02 03:50:07.0 +
+++ uip/mhical.c
@@ -714,7 +714,7 @@ display (FILE *file, contentline *clines
 }
 
 /* Don't call on the END:VCALENDAR line. */
-if (clines->next) {
+if (clines  &&  clines->next) {
   (void) fmt_scan (fmt, buffer, INT_MAX, dat, NULL);
   fputs (charstring_buffer (buffer), file);
   fmt_free (fmt, 1);
___
Nmh-workers mailing list
Nmh-workers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/nmh-workers