#48 segfault when encoding in ASCII

version 0.7.2
closed-fixed
encoding (12)
5
2011-03-09
2010-12-22
No

I'm experiencing a segfault when encoding certain binary files with ASCII encoding. With the attached file, the following command triggers the segfault on a Debian Squeeze AMD64 machine:
dmtxwrite -e a a_ad > /dev/null

If I change the encoding scheme to Base256 the segfault disappears.

The 0.7.2 version also contains various assertion failure with too big file (instead of clean error).
For exemple this one :
$ head -c 1600 /dev/zero > t && dmtxwrite -e 8 t > /dev/null
dmtxwrite: dmtxencode.c:1061: EncodeBase256Codeword: Assertion `newDataLength > 0 && newDataLength <= 1555' failed.

I have also triggered the assertion at dmtxencode.c:1224 but I can't find now how I did it.

Discussion

  • Mathias Kende

    Mathias Kende - 2010-12-22

    binary file which triggers the segfault

     
  • Mike Laughton

    Mike Laughton - 2010-12-26

    Thanks for the thorough bug report, Mathias. This will be helpful when we revisit the encoding logic.

     
  • Mike Laughton

    Mike Laughton - 2011-03-09
    • status: open --> closed-fixed
     
  • Mike Laughton

    Mike Laughton - 2011-03-09

    This bug has been addressed by a clean rewrite of the encoder (available in git HEAD). Examples:

    $ dmtxwrite -ea a_ad > /dev/null
    dmtxwrite: Unable to encode message (possibly too large for requested size)

    This behavior is correct since ASCII mode expands a_ad into more codewords than the largest Data Matrix can handle. At most I could fit the first 1161 bytes of a_ad:

    $ head -1161c a_ad | dmtxwrite -ea | dmtxread | wc -c
    1161

    Confirming the Base 256 scheme:

    $ md5sum a_ad
    9676de250641b4fb6e68cd3ca1123704 a_ad

    $ dmtxwrite -e8 a_ad | dmtxread | md5sum
    9676de250641b4fb6e68cd3ca1123704 -

    And the final example:

    $ head -c 1600 /dev/zero > t && dmtxwrite -e8 t > /dev/null
    dmtxwrite: Unable to encode message (possibly too large for requested size)

    This is another correctly issued error. Data Matrix can store up to 1556 bytes using Base 256, as confirmed here:

    $ head -c 1555 /dev/zero | dmtxwrite -e8 | dmtxread --verbose | sed -n '2p'
    Matrix Size: 144 x 144

    $ head -c 1556 /dev/zero | dmtxwrite -e8 | dmtxread --verbose | sed -n '2p'
    Matrix Size: 144 x 144

    $ head -c 1557 /dev/zero | dmtxwrite -e8 | dmtxread --verbose | sed -n '2p'
    dmtxwrite: Unable to encode message (possibly too large for requested size)

    Thanks Mathias for the bug report and test cases!

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks