Date: Mon, 17 Feb 2014 03:24:01 +0000 (UTC) From: Eitan Adler <eadler@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262011 - head/usr.bin/calendar Message-ID: <201402170324.s1H3O1Gk012399@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: eadler Date: Mon Feb 17 03:24:00 2014 New Revision: 262011 URL: http://svnweb.freebsd.org/changeset/base/262011 Log: calendar(1): don't segfault in invalid input When the user supplies an invalid number of days provide a useful error message instead of segfaulting. PR: bin/186697 Reported by: kaltheat <kaltheat@gmail.com> Submitted by: oliver <oliver@beefrankly.org> (older version) Modified: head/usr.bin/calendar/calendar.c Modified: head/usr.bin/calendar/calendar.c ============================================================================== --- head/usr.bin/calendar/calendar.c Mon Feb 17 02:24:58 2014 (r262010) +++ head/usr.bin/calendar/calendar.c Mon Feb 17 03:24:00 2014 (r262011) @@ -96,10 +96,14 @@ main(int argc, char *argv[]) case 'A': /* days after current date */ f_dayAfter = atoi(optarg); + if (f_dayAfter < 0) + errx(1, "number of days must be positive"); break; case 'B': /* days before current date */ f_dayBefore = atoi(optarg); + if (f_dayBefore < 0) + errx(1, "number of days must be positive"); break; case 'D': /* debug output of sun and moon info */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201402170324.s1H3O1Gk012399>