On Thu, Mar 12, 2015 at 12:05:28PM +0100, Karel Zak wrote: > 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 Yes, that works with my original testcase. has_term is better then *term misuse. > > --- 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". Ugh, sure. I have sent you older version of the patch, not the one from comment 6 of referenced bug. Thanks! Petr
Attachment:
signature.asc
Description: Digital signature