Your message dated Thu, 25 Jun 2026 20:35:57 +0000
with message-id <[email protected]>
and subject line Bug#1140643: fixed in wand 0.7.2-1
has caused the Debian Bug report #1140643,
regarding wand: Reads fail if file offsets are desynced
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1140643: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1140643
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Source: wand
Version: 0.7.1-1
Severity: normal
Tags: patch upstream

Dear Maintainer,

I discovered an upstream bug[1] which is causing migration issues on
Ubuntu[2].

Essentially, if the OS and Python file cursors ever get desynced, then
wand will pass the incorrect offset to ImageMagick. This was caused by
the move from RawIOBase to IOBase in the fix for upstream issue 675[3].

This problem can be reproduced on Debian by running a Python script
which first performs a buffered read and then seeks back to the
beginning:

```
from wand.image import Image

GIF = (b'GIF89a\x01\x00\x01\x00\x80\x00\x00\xff\xff\xff\x00\x00\x00!\xf9'

b'\x04\x01\x00\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;')
open("test.gif", "wb").write(GIF)

f = open("test.gif", "rb")
f.read(16)
f.seek(0)
Image(file=f)
```

Running this script on Debian will produce the error:

```
$ python3 test.py
Traceback (most recent call last):
  File "/root/wand/test.py", line 10, in <module>
    Image(file=f)
    ~~~~~^^^^^^^^
  File "/usr/lib/python3/dist-packages/wand/image.py", line 9632, in
__init__
    self.read(file=file)
    ~~~~~~~~~^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/wand/image.py", line 10488, in read
    self.raise_exception()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3/dist-packages/wand/resource.py", line 211, in
raise_exception
    raise e
wand.exceptions.MissingDelegateError: no decode delegate for this image
format `/tmp/magick-dnTm7mNPKK3qbsxOo1cdKU1ziBT5zdc8' @
error/constitute.c/ReadImage/755
```

I have added a patch which fixes this issue. I have also forwarded the
fix upstream[4], so this delta will eventually be dropped.

[1]: https://github.com/emcconville/wand/issues/688
[2]: https://bugs.launchpad.net/ubuntu/+source/wand/+bug/2158013
[3]: https://github.com/emcconville/wand/issues/675
[4]: https://github.com/emcconville/wand/pull/689
Description: Sync file offsets before reading
 A buffered Python file object can advance both the OS and the Python file
 cursor offsets. seek() can rewind the Python cursor without moving the OS
 cursor. wand cannot handle this situation and will pass the incorrect offset to
 ImageMagick.
 .
 This patch fixes this situation by forcing the OS cursor to match the object's
 logical position.
 .
 Non-seekable streams return OSError and closed objects return ValueError when
 attempting to lseek; in these cases the offset is left alone.
Author: Max Gilmour <[email protected]>
Bug: https://github.com/emcconville/wand/issues/688
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/wand/+bug/2158013
Forwarded: https://github.com/emcconville/wand/pull/689
Last-Update: 2026-06-23
---
--- a/wand/image.py
+++ b/wand/image.py
@@ -13,6 +13,7 @@
 import ctypes
 import functools
 import numbers
+import os
 import weakref
 from collections import abc
 from io import IOBase
@@ -9879,6 +9880,12 @@
                      callable(getattr(file, 'fileno', None)),
                      hasattr(file, 'mode'))
             if all(is_fd):
+                try:
+                    # Resync the fd offset before reading
+                    os.lseek(file.fileno(), file.tell(), os.SEEK_SET)
+                except (OSError, ValueError):
+                    # Do nothing if stream isn't seekable
+                    pass
                 fd = libc.fdopen(file.fileno(), binary(file.mode))
                 r = library.MagickPingImageFile(instance.wand, fd)
             elif not callable(getattr(file, 'read', None)):
@@ -10465,6 +10472,12 @@
                      callable(getattr(file, 'fileno', None)),
                      hasattr(file, 'mode'))
             if all(is_fd):
+                try:
+                    # Resync the fd offset before reading
+                    os.lseek(file.fileno(), file.tell(), os.SEEK_SET)
+                except (OSError, ValueError):
+                    # Do nothing if stream isn't seekable
+                    pass
                 fd = libc.fdopen(file.fileno(), binary(file.mode))
                 r = library.MagickReadImageFile(self.wand, fd)
             elif not callable(getattr(file, 'read', None)):

--- End Message ---
--- Begin Message ---
Source: wand
Source-Version: 0.7.2-1
Done: Håvard F. Aasen <[email protected]>

We believe that the bug you reported is fixed in the latest version of
wand, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Håvard F. Aasen <[email protected]> (supplier of updated wand package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Thu, 25 Jun 2026 21:11:40 +0200
Source: wand
Architecture: source
Version: 0.7.2-1
Distribution: unstable
Urgency: medium
Maintainer: Håvard F. Aasen <[email protected]>
Changed-By: Håvard F. Aasen <[email protected]>
Closes: 1140643
Changes:
 wand (0.7.2-1) unstable; urgency=medium
 .
   * New upstream release, Closes: #1140643.
Checksums-Sha1:
 9c0861bfa525d366324d2805b6b9927514ff8fdb 1455 wand_0.7.2-1.dsc
 277346141af1f3df508128a1c5c5ec3319cc9449 11878736 wand_0.7.2.orig.tar.gz
 c9dfa13f0dcc5646e224c943982febf1b305b49f 8692 wand_0.7.2-1.debian.tar.xz
 9e9577576d2dada51bc2d93a362df72ddb2513a2 8656 wand_0.7.2-1_amd64.buildinfo
Checksums-Sha256:
 986e17a148366f4b18239a9e16c542dc25d2586421a8f9c15d5189603210d48b 1455 
wand_0.7.2-1.dsc
 ad434962526c123eab92a46c8fc891de5b750504f8685a875e69afc95996da24 11878736 
wand_0.7.2.orig.tar.gz
 d979971e532a9c991ff1be61f4fadc2ee5f1fa414d70917215bbfa5e22156b52 8692 
wand_0.7.2-1.debian.tar.xz
 be5b3ab4438c81b8c9717dc4d5f171cba0298969aaf0dbc8529a90135e64b87c 8656 
wand_0.7.2-1_amd64.buildinfo
Files:
 807ed4d556ce108b6a4df4fe3effaaea 1455 python optional wand_0.7.2-1.dsc
 59c2b937f1f5ec0456fcd2eee0ef00e7 11878736 python optional 
wand_0.7.2.orig.tar.gz
 829652994c7ae1bb8f18c6d5223a34b5 8692 python optional 
wand_0.7.2-1.debian.tar.xz
 6988da5f0d13ced63fa1b61ab0981d30 8656 python optional 
wand_0.7.2-1_amd64.buildinfo

-----BEGIN PGP SIGNATURE-----

iI0EARYKADUWIQSD/42dLkLq3fzhpN2I4w6v/UfCtwUCaj2KxxccaGF2YXJkLmYu
YWFzZW5AcGZmdC5ubwAKCRCI4w6v/UfCt9h2AP4wGy2M5FJtKMLqRZ3K0R/PRX7I
eQ+0FCgM/fP1Bkk2rwD9H/mfiFZXvokGpE/HyuZ2cbTRKIkveaNZwZ3jHQCBpQ0=
=KMbF
-----END PGP SIGNATURE-----

Attachment: pgpsh_ly_3e6E.pgp
Description: PGP signature


--- End Message ---

Reply via email to