Re: Clib time functions



On Fri, 25 Jan 2008 14:44:51 +0100, Erik G wrote:

Here is what Harbison & Steele[1] say about this:

"In most implementations gmtime() and localtime() retrun a pointer to a
single static data area that is overwritten on every call. Therefore,
the returned structure should be used or copied before any subsequent
call to either function."

Their warning is not quite strong enough - from the C99 spec:

Except for the strftime function, these functions each return a pointer
to one of two types of static objects: a broken-down time structure or
an array of char. Execution of any of the functions that return a
pointer to one of these object types may overwrite the information in
any object of the same type pointed to by the value returned from any
previous call to any of them. The implementation shall behave as if no
other library functions call these functions.

The upshot is similar, but it's likely that any local or custom
extensions would follow this convention.

B.
.



Relevant Pages

  • Re: Where else?
    ... How do you plan to overwrite these? ... Dynamic loader hijack is also in ... pointer... ... Do You Yahoo!? ...
    (Vuln-Dev)
  • Re: Auto-add sites to Approved Sites
    ... or find out where those sites are stored and find some way to overwrite ... Thanks for the pointer, though. ... Matt ... Prev by Date: ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: [OT]
    ... Lawrence Kirby wrote: ... Just overwrite the node to be deleted with a ... This is uncritical -- a SecondToLast node pointer can be afforded ... having list nodes stay at the same location for their lifetime is ...
    (comp.lang.c)
  • Re: const function() !!??
    ... >> union type but nothing very interesting in this respect. ... > even attempt to modify the return value of a function, ... pointer to modify the value? ... If you assign the returned structure to ...
    (comp.lang.c)
  • Re: module confusion
    ... It just happens to contain a pointer to a module. ... Lawrence, you should have a look at CPython's source code. ... which implies that you can overwrite that memory location. ... But it has nothing to do with "overwriting a memory location" - like you could do in C using pointers. ...
    (comp.lang.python)

Loading