Closed PromptFuzz closed 10 months ago
Thanks for reporting. Indeed, this is not an error but the expected behavior. Remember this is C99 (not C++!) In C99 enums are assumed to fit in an int (32 bits in strict C99). You are compiling the code with clang++, which is not the required language. Lcms allows to open profiles with custom color spaces, as an ICC extension, despite the number then is not listed in the enum. This is perfectly valid in C99.
Thanks for reporting. Indeed, this is not an error but the expected behavior. Remember this is C99 (not C++!) In C99 enums are assumed to fit in an int (32 bits in strict C99). You are compiling the code with clang++, which is not the required language. Lcms allows to open profiles with custom color spaces, as an ICC extension, despite the number then is not listed in the enum. This is perfectly valid in C99.
Yes, i compiled it with clang++. The UBSan reported some errors confused me.
Thanks for your reply.
Summary
Hi, I found an UBSan error in lcms, that might by cause undefined behaviors in lcms.
it reported:
That might due to the
_cmsReadHeader
, called viacmsOpenProfileFromMem()->cmsOpenProfileFromMemTHR()->_cmsReadHeader()
, performed type cast toIcc -> ColorSpace
without check this vaule. The similar issue might also exist inIcc -> DeviceClass
,Icc -> PCS
andIcc -> platform
.Poc program
Steps to reproduce
clang++ -fsanitize=fuzzer,undefined -g -O0 -I/lcms/include poc.cc -o poc.out liblcms2.a
export UBSAN_OPTIONS=symbolize=1:print_stacktrace=1:halt_on_error=1
./poc.out crash-256553a6dfe1fb5be22ce6a3cc1618af1c3b68a6