Menu

#162 Does zbar/zbarimg support binary data with null bytes?

latest_mercurial
open
nobody
None
5
2016-11-26
2016-11-26
No

Seems like zbarimg fails to properly read qr codes with binary data if the data contains 0 (Null) bytes:

Sample input from /dev/urandom with 0 bytes:

$ ls -l from.bin 
-rw-rw-r-- 1 eseifert eseifert 200 Nov 21 10:57 from.bin
$ hexdump from.bin
0000000 3c76 94d4 3d8c c9ab 0b23 00a4 5e8d e208
0000010 f757 af75 fcd4 6372 70bf 7b41 58f4 af93
0000020 5595 36a2 f8d6 e604 bdfc a17d 7e36 3fb7
0000030 155e 7424 02f5 8923 98e0 9c4d 6a73 bc0a
0000040 27da cdd5 47e5 871f 5250 17c8 5cb2 c831
0000050 affe b014 b57b d11e 2b7f c4a8 4950 e45f
0000060 8b0a 5711 77c1 9518 3161 e4cf 2821 ad12
0000070 66ba 3733 08fd a173 c4c0 1667 67ee b276
0000080 2819 fd66 7452 bae2 c067 82ce 16b5 b359
0000090 a509 50ef c288 a404 a1aa 0e3e 3df0 bbbb
00000a0 91af 001c 7736 537f d246 6bff f1d4 3f81
00000b0 124d 04ea 8ac0 a97d 439b a65b 840d ed34
00000c0 79a5 9204 7dbe dbd1                    
00000c8

Create qr code:

$ qrencode -8 -o out.png -s 8 < from.bin

Decode qr code:

$ zbarimg -q --raw out.png | iconv -f UTF-8 -t ISO-8859-1 > to.bin

Results:

$ ls -l to.bin 
-rw-rw-r-- 1 eseifert eseifert 12 Nov 21 17:11 to.bin
$ hexdump to.bin 
0000000 3c76 94d4 3d8c c9ab 0b23 0aa4          
000000c

Looks like it stopped on the first 0 byte (zbarimg adds a newline at the end, but I was aware of this)

Am I doing something wrong? I should be able to decode arbitrary binary data with this right?

PS: iconv part is needed for binary data, I found in a post here: https://sourceforge.net/p/zbar/support-requests/131/

$ uname -a
Linux samwise 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ zbarimg --version
0.10

Discussion


Log in to post a comment.