Re: Questions about C1x
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Wed, 07 Jan 2009 08:43:39 -0800
jacob navia <jacob@xxxxxxxxxx> writes:
[...]
Because if you give it a year bigger than 8899, adding 1900 to it[...]
will produce a number >= 10 000. This means that 5 positions of the
output buffer will be used isntead of 4, overwriting the terminating
zero.
This is a buffer overflow where there isn't any access to the [ ]
operator. As I told you before, I am not speaking about the possibility
that the month is bigger than 12, making it index a wrong position in
the table of months names. I am NOT speaking about THAT possibility.
I am speaking about the fact that any year bigger than 8899 will
overflow the buffer. No limitations are specified for that value.
The same problem happens if you pass it a negative value bigger than
-2899.
This is all correct. If you call asctime() with a tm_year value
greater than 8899 or less than -2899, the behavior is undefined.
If you call it with a tm_year value inside that range, and all other
members of the struct tm are within ranges that can also be easily
determined, then the behavior is well defined.
(asctime() *can* be used perfectly safely if the programmer exercises
a bit of care. In particular, it can be used safely with a struct
tm value generated by gmtime() or localtime() for the current time
for the next several thousand years.)
And you were able to derive all this information from the standard's
description of asctime(). Anyone else could derive the same
information.
The problem you keep complaining about doesn't exist, at least
not in the severe form that you claim.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: Questions about C1x
- From: Ike Naar
- Re: Questions about C1x
- From: jacob navia
- Re: Questions about C1x
- References:
- Re: Questions about C1x
- From: David R Tribble
- Re: Questions about C1x
- From: jacob navia
- Re: Questions about C1x
- From: Wojtek Lerch
- Re: Questions about C1x
- From: jacob navia
- Re: Questions about C1x
- From: Keith Thompson
- Re: Questions about C1x
- From: jacob navia
- Re: Questions about C1x
- From: Wojtek Lerch
- Re: Questions about C1x
- From: jacob navia
- Re: Questions about C1x
- From: Wojtek Lerch
- Re: Questions about C1x
- From: jacob navia
- Re: Questions about C1x
- Prev by Date: Re: Questions about C1x
- Next by Date: Re: Questions about C1x
- Previous by thread: Re: Questions about C1x
- Next by thread: Re: Questions about C1x
- Index(es):
Relevant Pages
|