Util-Linux package development
 help / color / mirror / Atom feed
From: Petr Gajdos <pgajdos@suse.cz>
To: util-linux@vger.kernel.org
Subject: Re: prevent cal segfault
Date: Thu, 12 Mar 2015 13:00:05 +0100	[thread overview]
Message-ID: <20150312120005.GA10879@laura.suse.cz> (raw)
In-Reply-To: <20150312110528.GA4637@ws.net.home>

[-- Attachment #1: Type: text/plain, Size: 1387 bytes --]

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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

      reply	other threads:[~2015-03-12 12:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-12  8:46 prevent cal segfault Petr Gajdos
2015-03-12  9:10 ` Ruediger Meier
2015-03-12 11:05 ` Karel Zak
2015-03-12 12:00   ` Petr Gajdos [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150312120005.GA10879@laura.suse.cz \
    --to=pgajdos@suse.cz \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox