From: Karel Zak <kzak@redhat.com>
To: Petr Gajdos <pgajdos@suse.cz>
Cc: util-linux@vger.kernel.org
Subject: Re: prevent cal segfault
Date: Thu, 12 Mar 2015 12:05:28 +0100 [thread overview]
Message-ID: <20150312110528.GA4637@ws.net.home> (raw)
In-Reply-To: <20150312084639.GC9756@laura.suse.cz>
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@redhat.com>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2015-03-12 11:05 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 [this message]
2015-03-12 12:00 ` Petr Gajdos
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=20150312110528.GA4637@ws.net.home \
--to=kzak@redhat.com \
--cc=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