Re: prevent cal segfault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 12, 2015 at 09:46:39AM +0100, Petr Gajdos wrote:
> cal utility segfaults in putp() when setupterm() fails as cal
> insufficiently checks for setupterm() failure.
> 
> $ TERM= cal
> Segmentation fault

I'm not able to reproduce this problem. Anyway you're right that the
current code is pretty fragile and ignore setupterm() return code is
bad idea.

I have applied a little bit different patch, please test it in your
environment. The patch is also in stable/v2.26 (for v2.26.1).

https://github.com/karelzak/util-linux/commit/2a4b073e8b2d34dfadd8306f7d71957687923bdd


Note that I have doubts we really need so many fallbacks in cal(1)
code. IMHO it would be enough to support two ways: ncurses or just
without any extra terminal support (so stdio.h only). I'll probably 
cleanup this for v2.27 to make the code more maintainable. 

> --- misc-utils/cal.c.orig	2014-08-26 16:48:45.132654654 +0200
> +++ misc-utils/cal.c	2015-03-11 14:16:06.075064939 +0100
> @@ -81,14 +81,22 @@
>  # endif
>  # include <term.h>
>  
> -static void my_setupterm(const char *term, int fildes, int *errret)
> +#if defined(HAVE_LIBNCURSES) || defined(HAVE_LIBNCURSESW) || defined(HAVE_LIBTERMCAP)
> +static const char	*term="";
> +#endif

This seems incorrect, you have moved "#if defined" into another "#if".

    Karel


-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux