You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2020/11/27 16:54:50 UTC

svn commit: r1883868 - /apr/apr/trunk/encoding/apr_encode.c

Author: ylavic
Date: Fri Nov 27 16:54:50 2020
New Revision: 1883868

URL: http://svn.apache.org/viewvc?rev=1883868&view=rev
Log:
apr_encode_base32: fix estimated output *len (when called with src == NULL).

Modified:
    apr/apr/trunk/encoding/apr_encode.c

Modified: apr/apr/trunk/encoding/apr_encode.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/encoding/apr_encode.c?rev=1883868&r1=1883867&r2=1883868&view=diff
==============================================================================
--- apr/apr/trunk/encoding/apr_encode.c (original)
+++ apr/apr/trunk/encoding/apr_encode.c Fri Nov 27 16:54:50 2020
@@ -665,7 +665,7 @@ APR_DECLARE(apr_status_t) apr_encode_bas
     }
 
     if (len) {
-        *len = ((slen + 2) / 3 * 4) + 1;
+        *len = ((slen + 4) / 5 * 8) + 1;
     }
 
     return APR_SUCCESS;



Re: svn commit: r1883868 - /apr/apr/trunk/encoding/apr_encode.c

Posted by Yann Ylavic <yl...@gmail.com>.
[Joint response]

On Mon, Nov 30, 2020 at 10:27 AM Ruediger Pluem <rp...@apache.org> wrote:
>
> If src == NULL we leave immediately with APR_NOTFOUND. How does the below change this?

On Mon, Nov 30, 2020 at 9:56 PM Graham Leggett <mi...@sharp.fm> wrote:
>
> A small detail - the API returns exact lengths across all apr_encode calls, none of these are estimates.

Bad commit message, propedit-ed in both trunk and 1.7.x.


On Mon, Nov 30, 2020 at 10:27 AM Ruediger Pluem <rp...@apache.org> wrote:
>
> This creates a much larger result. If slen == 1  e.g. 5 vs 9

That's what's needed for base32. I think the code/formula was taken
from base64, and only apr_encode_base32_binary()'s formula was
adjusted.


Regards;
Yann.

Re: svn commit: r1883868 - /apr/apr/trunk/encoding/apr_encode.c

Posted by Ruediger Pluem <rp...@apache.org>.

On 11/27/20 5:54 PM, ylavic@apache.org wrote:
> Author: ylavic
> Date: Fri Nov 27 16:54:50 2020
> New Revision: 1883868
> 
> URL: http://svn.apache.org/viewvc?rev=1883868&view=rev
> Log:
> apr_encode_base32: fix estimated output *len (when called with src == NULL).


If src == NULL we leave immediately with APR_NOTFOUND. How does the below change this?

> 
> Modified:
>     apr/apr/trunk/encoding/apr_encode.c
> 
> Modified: apr/apr/trunk/encoding/apr_encode.c
> URL: http://svn.apache.org/viewvc/apr/apr/trunk/encoding/apr_encode.c?rev=1883868&r1=1883867&r2=1883868&view=diff
> ==============================================================================
> --- apr/apr/trunk/encoding/apr_encode.c (original)
> +++ apr/apr/trunk/encoding/apr_encode.c Fri Nov 27 16:54:50 2020
> @@ -665,7 +665,7 @@ APR_DECLARE(apr_status_t) apr_encode_bas
>      }
>  
>      if (len) {
> -        *len = ((slen + 2) / 3 * 4) + 1;
> +        *len = ((slen + 4) / 5 * 8) + 1;

This creates a much larger result. If slen == 1  e.g. 5 vs 9

>      }
>  
>      return APR_SUCCESS;
> 
> 
> 

Regards

Rüdiger

Re: svn commit: r1883868 - /apr/apr/trunk/encoding/apr_encode.c

Posted by Graham Leggett <mi...@sharp.fm>.
On 27 Nov 2020, at 18:54, ylavic@apache.org wrote:

> URL: http://svn.apache.org/viewvc?rev=1883868&view=rev
> Log:
> apr_encode_base32: fix estimated output *len (when called with src == NULL).

A small detail - the API returns exact lengths across all apr_encode calls, none of these are estimates.

>     if (len) {
> -        *len = ((slen + 2) / 3 * 4) + 1;
> +        *len = ((slen + 4) / 5 * 8) + 1;
>     }

Good catch.

Regards,
Graham
—