[go: up one dir, main page]

Menu

#6 Decoding Error

v1.0 (example)
closed-fixed
nobody
None
5
2015-10-29
2013-03-20
No

If you decode a string that doesn't have any padding characters, the final character is not returned.

Examples (from the review) 'Z2lhbmx1Y2E6YXNkYXNk' decodes as 'gianluca:asdas' but adding an unnecessary padding character (note any character I tried also worked, 'a', a carriage return, etc): 'Z2lhbmx1Y2E6YXNkYXNk=' decodes as 'gianluca:asdasd'

From Wikipedia (I added single quotes around the encoded text and decoded text for clarity)
'YW55IGNhcm5hbCBwbGVhcw==' Block with 2 '='s decodes to 1 character: 'any carnal pleas'
this decodes correctly

'YW55IGNhcm5hbCBwbGVhc3U=' Block with 1 '=' decodes to 2 characters: 'any carnal pleasu'
this decodes correctly

'YW55IGNhcm5hbCBwbGVhc3Vy' Block with 0 '='s decodes to 3 characters: 'any carnal pleasur'
this decodes as 'any carnal pleasu'

Related

Bugs: #6

Discussion

  • Takashi Ando

    Takashi Ando - 2014-03-04

    it seems that b64.c has wrong code at line 374.
    putc() returns EOF if some error, so the line 374 should be like below.

    if(putc((int)out[i],outfile)==EOF){
    if(ferror()){
    ...
    }
    }

     
    • Bob Trower

      Bob Trower - 2014-03-04

      Thanks so much for the report. I am astonished that after all this time
      there actually appears to be an honest to goodness bug in the code.

      I will have to review the unit tests to see if I can somehow simulate this.
      This would only become a problem if there is a write error. I did test
      the code for write errors, but it was limited because it was hard to set
      up. The way disk space is allocated I am not even sure if the error can be
      created.

      I receive bug reports from time to time but they are always because someone
      has ripped out some of the code and are making an invalid call into one of
      the functions.

      Thanks again for making the report. I will review in the next couple of
      days and if, as it appears, it is a bug, I will publish corrected code.

      Cheers!

      Bob Trower

      On Mon, Mar 3, 2014 at 8:20 PM, Takashi Ando dodo5522@users.sf.net wrote:

      it seems that b64.c has wrong code at line 374.
      putc() returns EOF if some error, so the line 374 should be like below.

      if(putc((int)out[i],outfile)==EOF){
      if(ferror()){
      ...
      }
      }


      Status: open
      Group:
      Created: Wed Mar 20, 2013 05:55 PM UTC by John Peterson
      Last Updated: Wed Mar 20, 2013 05:55 PM UTC
      Owner: nobody

      If you decode a string that doesn't have any padding characters, the final
      character is not returned.

      Examples (from the review) 'Z2lhbmx1Y2E6YXNkYXNk' decodes as
      'gianluca:asdas' but adding an unnecessary padding character (note any
      character I tried also worked, 'a', a carriage return, etc):
      'Z2lhbmx1Y2E6YXNkYXNk=' decodes as 'gianluca:asdasd'

      From Wikipedia (I added single quotes around the encoded text and decoded
      text for clarity)
      'YW55IGNhcm5hbCBwbGVhcw==' Block with 2 '='s decodes to 1 character: 'any
      carnal pleas'
      this decodes correctly

      'YW55IGNhcm5hbCBwbGVhc3U=' Block with 1 '=' decodes to 2 characters: 'any
      carnal pleasu'
      this decodes correctly

      'YW55IGNhcm5hbCBwbGVhc3Vy' Block with 0 '='s decodes to 3 characters: 'any
      carnal pleasur'
      this decodes as 'any carnal pleasu'


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/base64/bugs/6/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #6

  • Bob Trower

    Bob Trower - 2015-10-29

    Code has been updated to version 0.94R and it has a small test added to ensure that binary code (the b64.exe file itself) is encoded and then decoded properly.

    Many thanks to people who reviewed and reported this. It was very easy to find and fix things because of the reports showing exactly the symptom and even the offending lines of code.

     
  • Bob Trower

    Bob Trower - 2015-10-29
    • status: open --> closed-fixed
    • Group: --> v1.0 (example)
     
  • Bob Trower

    Bob Trower - 2015-10-29
     
  • Bob Trower

    Bob Trower - 2015-10-29

    Fixed Release 0.94R

     

Log in to post a comment.