*BSD News Article 34344


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msuinfo!agate!howland.reston.ans.net!pipex!sunic!trane.uninett.no!eunet.no!nuug!EU.net!uunet!brunix!mhw
From: mhw@cs.brown.edu (Mark Weaver)
Subject: Re: FreeBSD 1.1.5 -- Bug in /usr/bin/leave
Message-ID: <1994Aug15.034212.20767@cs.brown.edu>
Sender: news@cs.brown.edu
Organization: Brown University Department of Computer Science
References: <NILS.94Aug14230659@guru.stgt.sub.org>
Date: Mon, 15 Aug 1994 03:42:12 GMT
Lines: 43

Your fix doesn't change the program at all.  In C, "&&" has a higher
precedence than "||", and both have a lower precedence than the
comparison operators.  I don't know why you thought this changed
anything, but I'm sure it didn't.

	Mark

In article <NILS.94Aug14230659@guru.stgt.sub.org>,
Cornelis van der Laan <nils@ims.uni-stuttgart.de> wrote:
>
>There's a bug in /usr/bin/leave, causing it to not properly handle 
>argument times.
>
>Repeat by:
>	At 22:50 try to set an alarm for 24:00 (ok, that's not possible, 
>	so let's take 23:59).
>
>	leave 2359 responds with: usage: leave [[+]hhmm]
>
>The fix is to insert missing parentheses around a conjunctive condition:
>
>*** leave.c     Sun Aug 14 22:59:58 1994
>--- leave.c.orig        Sun Aug 14 22:59:26 1994
>***************
>*** 97,103 ****
>                secs = hours * 60 * 60 + minutes * 60;
>        else {
>                if (hours > 23 || t->tm_hour > hours ||
>!                   t->tm_hour == hours && minutes <= t->tm_min)
>                        usage();
>                secs = (hours - t->tm_hour) * 60 * 60;
>                secs += (minutes - t->tm_min) * 60;
>--- 97,103 ----
>                secs = hours * 60 * 60 + minutes * 60;
>        else {
>                if (hours > 23 || t->tm_hour > hours ||
>!                   (t->tm_hour == hours && minutes <= t->tm_min))
>                        usage();
>                secs = (hours - t->tm_hour) * 60 * 60;
>                secs += (minutes - t->tm_min) * 60;
--------------------------------------------------------------------
Email: Mark_Weaver@brown.edu           | Brown University
PGP Key: finger mhw@cs.brown.edu       | Dept of Computer Science