Skip to content

Commit 0f008f9

Browse files
authored
fix(sgi): Fix valid_file to properly swap bytes on little-endian platforms (#4697)
The SGI IRIS format is big-endian so incoming multi-byte fields need to be swapped. This wasn't being done in the `valid_file` call so the magic test would always fail on little-endian platforms. Signed-off-by: Jesse Yurkovich <jesse.y@gmail.com>
1 parent bb70340 commit 0f008f9

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/sgi.imageio/sgiinput.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ SgiInput::valid_file(Filesystem::IOProxy* ioproxy) const
8989

9090
int16_t magic {};
9191
const size_t numRead = ioproxy->pread(&magic, sizeof(magic), 0);
92+
if (littleendian()) {
93+
swap_endian(&magic);
94+
}
9295
return numRead == sizeof(magic) && magic == sgi_pvt::SGI_MAGIC;
9396
}
9497

0 commit comments

Comments
 (0)