The format string is a multiplier of length. 4k repeated %Y elements in
the 'a' variable's format string is 8kbytes in the format string, but the
result would take 16kbytes. Then you have things like %B: the full month
name according to the current locale. You cannot really predict the length
without actually doing the strftime.
I figured 256 bytes is more than reasonable. Normal time strings are < 32
bytes; double that, and quadruple that again (e.g. if there are utf-8 chars
in the string), and you get 256 bytes. If people need more, one can use in
LogFormat %{formatstring1}t%{formatstring2}t.
On Fri, Dec 13, 2013 at 10:14 AM, Yann Ylavic <[email protected]> wrote:
> On Fri, Dec 13, 2013 at 5:06 AM, Daniel Lescohier <
> [email protected]> wrote:
>
>> Here is my draft replacement:
>>
>> static const char *log_request_time_custom(request_rec *r, char *a,
>> apr_time_exp_t *xt)
>> {
>> static const apr_size_t buf_len = 256;
>> apr_size_t tstr_len;
>> char *tstr = apr_palloc(r->pool, buf_len);
>>
>> apr_strftime(tstr, &tstr_len, buf_len, a, xt);
>> return tstr_len ? tstr : "-";
>> }
>>
>
> Shouldn't [MAX_STRING_LEN > buf_len > strlen(a)] for apr_strftime() not to
> truncate the result (for any resonnable 'a')?
>
>