antonscheffer / as_barcode

A PL/SQL package to create a QR-code, Aztec or datamatrix barcode.
MIT License
25 stars 8 forks source link

calculated length of chunk IDAT too high by 4 bytes #3

Closed r13ssh closed 2 years ago

r13ssh commented 7 years ago

Hi Anton,

awesome tool, thanks alot for putting it together !

Small note: I think the logic to calc the length of the chunk IDAT has a small typo, instead of "+ 4" it should read "- 4" (probably just a typo), i.e.

...
    return utl_raw.concat( '89504E470D0A1A0A' -- signature 
                         , '0000000D'
                         , t_ihdr
                         , crc32( t_ihdr )
                         , to_char( utl_raw.length( t_idat ) - 4, 'fm0XXXXXXX' ) 
                         , t_idat 
                         , crc32( t_idat ) 
                         , '0000000049454E44AE426082' -- IEND
                         );
...

As far as I can understand, the length of a chunk should only include the length of the data, not the chunk type, the length of the chunk or the CRC of the chunk (found this note here).

We stumbled across the issue because Oracle XML Publisher wouldn't render the PNG (while Oracle's BI Publisher would ;-)); after verifying the PNG file itself using pngcheck we found the issue.

thanks alot for looking into this! Herbert

antonscheffer commented 2 years ago

Solved