On 6/29/20 7:45 PM, minf...@apache.org wrote: > Author: minfrin > Date: Mon Jun 29 17:45:35 2020 > New Revision: 1879346 > > URL: http://svn.apache.org/viewvc?rev=1879346&view=rev > Log: > Use a dedicated constant for the base64 sha1 length. > > Modified: > httpd/httpd/trunk/server/util_etag.c > > Modified: httpd/httpd/trunk/server/util_etag.c > URL: > http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_etag.c?rev=1879346&r1=1879345&r2=1879346&view=diff > ============================================================================== > --- httpd/httpd/trunk/server/util_etag.c (original) > +++ httpd/httpd/trunk/server/util_etag.c Mon Jun 29 17:45:35 2020 > @@ -29,6 +29,8 @@ > #include "http_protocol.h" /* For index_of_response(). Grump. */ > #include "http_request.h" > > +#define SHA1_DIGEST_BASE64_LEN 4*(APR_SHA1_DIGESTSIZE/3) Thanks for the better readability, but using apr_base64_encode_len this would result in (APR_SHA1_DIGESTSIZE + 2) / 3 * 4) + 1 Why is the calculation different here (Ok I guess '+ 1' in the above is for the final '\0' which we do not need to take account for here)? > + > /* Generate the human-readable hex representation of an apr_uint64_t > * (basically a faster version of 'sprintf("%llx")') > */ > @@ -168,7 +170,7 @@ AP_DECLARE(char *) ap_make_etag_ex(reque > } > > etag = apr_palloc(r->pool, weak_len + sizeof("\"\"") + > - 4*(APR_SHA1_DIGESTSIZE/3) + vlv_len + 4); > + SHA1_DIGEST_BASE64_LEN + vlv_len + 4); Tab issue? And why + 4? I see the need for - a '\0' at the end - I assume that vlv contains the closing '"', hence this is accounted for in vlv_len if a vlv is present - sizeof("\"\"") takes care of the leading '"' (after a possible weak string) and of the closing '"' in case of no vlv and of the ';' in case of a vlv. This would result in + 2. Regards RĂ¼diger