#381 bad base64 error report

lisp error
closed-fixed
clisp (524)
5
2006-11-14
2006-11-13
No

(ext:convert-string-to-bytes "AAAAB" charset:base64)
*** - Invalid base64 encoding at
#\CYRILLIC_CAPITAL_LETTER_IE_WITH_GRAVE (character 5 of 5)

(ext:convert-string-to-bytes "AAAABB" charset:base64)
*** - Invalid base64 encoding at #<ADDRESS #xBEE4D710>
(character 6 of 6)
The following restarts are available:

The bug is that in encoding.d:base64_wcstombs(),
error_p is out of bounds, *error_p is garbage.

Discussion

  • Sam Steingold

    Sam Steingold - 2006-11-13

    Logged In: YES
    user_id=5735

    thanks. here is the patch:

    --- encoding.d 20 Jun 2006 18:02:20 -0400 1.132
    +++ encoding.d 13 Nov 2006 11:32:47 -0500
    @@ -235,11 +235,16 @@
    var const chart *error_p = NULL;
    *destp += base64_to_bytes(*srcp,srcend,*destp,&error_p);
    if (error_p) {
    - pushSTACK(fixnum(srcend-*srcp));
    + if (error_p == srcend) {
    pushSTACK(fixnum(error_p-*srcp));
    + fehler(charset_type_error,GETTEXT("Invalid base64
    encoding at end of string (position ~S)"));
    + } else {
    + pushSTACK(fixnum(srcend-*srcp));
    + pushSTACK(fixnum((error_p-*srcp)+1));
    pushSTACK(code_char(*error_p));
    fehler(charset_type_error,GETTEXT("Invalid base64
    encoding at ~S (character ~S of ~S)"));
    }
    + }
    *srcp = srcend;
    }

     
  • Jörg Höhle

    Jörg Höhle - 2006-11-13

    Logged In: YES
    user_id=377168

    I find the wording "at end of string" unfortunate given the
    :END argument to convert-string-to-bytes.
    (ext:convert-string-to-bytes "AAAABCDEF" charset:base64 :end 5)
    is somehow not at end of (the visible) string.

    Perhaps "illegal termination of base64 encoding" or some such?
    -- Since what's missing is one or two #\=

     
  • Sam Steingold

    Sam Steingold - 2006-11-14

    Logged In: YES
    user_id=5735

    thank you for your bug report.
    the bug has been fixed in the CVS tree.
    you can either wait for the next release (recommended)
    or check out the current CVS tree (see http://clisp.cons.org\)
    and build CLISP from the sources (be advised that between
    releases the CVS tree is very unstable and may not even build
    on your platform).

     
  • Sam Steingold

    Sam Steingold - 2006-11-14
    • labels: --> clisp
    • status: open --> closed-fixed
     

Log in to post a comment.