[Lcms-user] Unexpected behaviour of cmsReadRawTag
An ICC-based CMM for color management
Brought to you by:
mm2
|
From: Richard H. <hug...@gm...> - 2013-05-11 09:49:28
|
Hi all, I'm trying to read the first 4 bytes from a profile (to get the tag type), and I'm doing something like this: cmsTagSignature sig; char buffer[4]; sig = cmsGetTagSignature(hProfile, i); tag_size = cmsReadRawTag(hProfile, sig, buffer, 4); This returns the correct tag_size, but running this under valgrind seems to suggest that rather than writing 4 bytes into buffer (which is what I asked for), tag_size bytes seem to be written. This makes buffer overflow, and depending on how forgiving the compiler has been and the size of the raw tag, the program crashes in random places. Throw -fPIE into the mix and it crashes every time. I'm not completely sure how to fix this, as MemIO->Tell is used to return the size of the tag, which isn't going to be correct if the buffer size is too small to fit the entire tag in. I couldn't see a better way to extract the cmsTagTypeSignature when iterating cmsGetTagCount, maybe an accessor is also a good idea. Ideas very welcome, thanks. Richard. |