You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Marc Slemko <ma...@worldgate.com> on 1998/11/01 01:30:07 UTC

Re: [PATCH] Win32 strftime

On Tue, 27 Oct 1998, Manoj Kasichainula wrote:

> The win32 strftime seems to be deficient. It doesn't provide certain
> %-expandos that other platforms do. So, Ken Parzygnat and I built a
> strftime-adapter that handles the extra expandos and passes the
> partially digested result to the real strftime. This allows things
> that depend on strftime, such as SSI, to have a consistent interface
> available. The patch is attached.

The use of malloc() isn't safe because we could timeout in the middle.
Likely?  No.  Possible?  Yes, and some freak could result in the Win32
strftime() blocking for some reason, etc.  I'm assuming the Win32 timeouts
do longjmp or something similar that jumps out of the current frame and to
wherever.  You can use alloca as an alternative if it works on Win32.

Other than that, looks ok.

Note that the assumption of a format string bigger than max --> a result
string bigger than max isn't valid.

eg. strftime(out, 6, "%%%%%%%%%%") is valid.  If you change 6 to 600 and
give 1200 '%'s instead, then it looks like your code will fail;
gracefully, but still a fail.  I wouldn't worry about that one though.

Re: [PATCH] Win32 strftime

Posted by Manoj Kasichainula <ma...@raleigh.ibm.com>.
On Sat, Oct 31, 1998 at 05:30:07PM -0700, Marc Slemko wrote:
> The use of malloc() isn't safe because we could timeout in the middle.

Ouch. yes.

> You can use alloca as an alternative if it works on Win32.

In util_win32.c, _alloca seems to be used instead. In http_main.c,
it's just alloca. Is _alloca preferred on Win32?

> eg. strftime(out, 6, "%%%%%%%%%%") is valid.  If you change 6 to 600 and
> give 1200 '%'s instead, then it looks like your code will fail;
> gracefully, but still a fail.  I wouldn't worry about that one though.

This case actually wouldn't be too hard to fix. If "%%" is handled in
the adapter function as well, then this case is taken care of. There
are other cases where this can crop up, though. "%p" supposedly
returns nothing in some locales. The only way to truly fix this would
be to add a full strftime-implementation, or to throw in some reallocs.

After adding a "%%" check and fixing the malloc, are there any objections?