Package: python3-pylibdmtx
Version: 0.1.10-1
Severity: important

Dear Maintainer,

I use libdtmx to place 2D codes with compressed and encrypted (and therefore binary) content. I have found that the decode routine truncates the decoded content at the first null byte. It seems that it incorrectly uses C-strings to pass the data between the library and Python.
The dmtxread utility correctly decodes such contents.
I send the demonstrator files:
1) demo.png - the 2D code with binary content containing a null byte in the middle, 2) demo_bug.py - the Python scripts, which decodes only 37 bits (run it and it will produce the 37 bit long demo_out_0.bin)
If you run:
dmtxread demo.png > demo_ok.bin
you'll get the 111 bytes long demo_ok.bin with correctly decoded data.

-- System Information:
Debian Release: bookworm/sid
APT prefers testing
APT policy: (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.0.0-4-amd64 (SMP w/12 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=pl_PL.UTF-8, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages python3-pylibdmtx depends on:
ii libdmtx0b 0.7.5-3+b1
ii python3 3.10.6-1
ii python3-pil 9.2.0-1.1+b1

python3-pylibdmtx recommends no packages.

python3-pylibdmtx suggests no packages.

-- no debconf information

#!/usr/bin/python
from pylibdmtx.pylibdmtx import decode
from PIL import Image
# Read the scanned test
img = Image.open("demo.png")
if img.mode != 'RGB':
   img = img.convert('RGB')
# The timeout value (and other options) below may need adjustment
# If you know any better way how to reasonable control
# precision of the dmtx decoding, please let me know
dm_read=decode(img)
for i in range(0,len(dm_read)):
    fout="demo_out_"+str(i)+".bin"
    with open(fout,"wb") as fo:
       fo.write(dm_read[i].data)


Reply via email to