Re: lcc-win32

From: CBFalconer (cbfalconer_at_yahoo.com)
Date: 10/10/04


Date: Sun, 10 Oct 2004 03:38:19 GMT

jacob navia wrote:
>
>> I don't believe that, and your remark is close to libel by the
>> way. I'm prepared to believe that the committee doesn't consider
>> it worth correcting at this stage, as its a trivial error much
>> along the same lines as a spelling mistake.[snip]
>
> Mr Clive Feather presented a defect report for this bug, dated
> 2001, September 4th.
>
> The answer of the comitee was:
> [snip]
> asctime() may exhibit undefined behavior if any of the members of
> timeptr produce undefined behavior in the sample algorithm (for
> example, if the timeptr->tm_wday is outside the range 0 to 6 the
> function may index beyond the end of an array).
> As always, the range of undefined behavior permitted includes:
> Corrupting memory
> [snip]
>
> I think that this was the wrong answer to give to a bug report.
> Problem is, bugs do not go away. You have to correct them.
>
> Either the standard doesn't print any code (and there are
> *many* other functions where writing more code would have been
> useful) or then it prints a *correct* algorithm. Functions that
> corrupt memory at the slightest error or malitious inputs
> should be banned.

No, you can use it perfectly safely. All you have to do is check
the arguments before calling it. If erroneous you can then decide
how to compensate. For example, you can restrict the year range to
-999 .. 9999, and then correct the returned string if the original
was otherwise. It is under your control, unlike gets where the
faulty action is uncontrollable.

If you wish you can write a supervisory function to do the error
checking and return whatever you wish as an error signal. No
language change is needed, and old software will continue to
compile and run as expected.

-- 
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
   <http://cbfalconer.home.att.net>  USE worldnet address!


Relevant Pages

  • Re: lcc-win32
    ... timeptr produce undefined behavior in the sample algorithm (for example, ... Corrupting memory ... I think that this was the wrong answer to give to a bug report. ...
    (comp.lang.c)
  • Re: lcc-win32
    ... >> Mr Clive Feather presented a defect report for this bug, ... >> timeptr produce undefined behavior in the sample algorithm (for ... >> I think that this was the wrong answer to give to a bug report. ...
    (comp.lang.c)
  • Re: worst.c - foolishness
    ... My change merely replaces "undefined behavior upon calling ... > my bug is much subtler. ... > will store a number in 'foo', and then, assuming the user has pressed ... I don't like the doublecheck for eof though. ...
    (comp.lang.c)
  • Re: Buffer overflows and asctime()
    ... legalese tend to get lost in their word mazes and loose ... the technical knowledge that should be the basis of ... what is a BUG and how to fix it. ... This call to strcpyinvokes undefined behavior. ...
    (comp.std.c)
  • Re: worst.c - foolishness
    ... Note the subtle change ... it's one bug less if you ignore the misdefinition.. ... elsewhere) with "undefined behavior upon passing NULL to feof". ... will store a number in 'foo', and then, assuming the user has pressed ...
    (comp.lang.c)