Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dumping negative ImageIFD.TimeZoneOffset causes struct.error: argument out of range #135

Open
davetapley opened this issue Jul 5, 2022 · 1 comment

Comments

@davetapley
Copy link

Per ISO/DIS 12234-2:

Time Zone Offset (in hours) of DateTimeOriginal tag-value relative to Greenwich Mean Time

and:

The allowed values are -12 to +11.

but:

34858: {'name': 'TimeZoneOffset', 'type': TYPES.Long},

then:

Piexif/piexif/_dump.py

Lines 206 to 209 in 3422fbe

elif value_type == TYPES.Long:
length = len(raw_value)
if length <= 1:
value_str = _pack_long(*raw_value)

and:

Piexif/piexif/_dump.py

Lines 173 to 174 in 3422fbe

def _pack_long(*args):
return struct.pack(">" + "L" * len(args), *args)

where L is unsigned long, causing ⬇️ for dump with any negative offset.

struct.error: argument out of range
@davetapley
Copy link
Author

Fix for this will go in after #122

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant