-
Notifications
You must be signed in to change notification settings - Fork 74
Description
Freeimage has several different vulnerabilities in it and the library is no longer maintained and has not been updated since 2018.
Because of this, it has been dropped from many different distributions, such as nixpkgs: NixOS/nixpkgs#454867
This makes building gazebo on those distributions more difficult.
It does not seem that freeimage is used that extensively within gazebo, it is basically only present in a single place:
gz-rendering/optix/src/OptixTextureFactory.cc
Lines 54 to 110 in a395a95
| optix::Buffer OptixTextureFactory::CreateBuffer(const std::string &_filename) | |
| { | |
| if (_filename.empty()) | |
| { | |
| gzerr << "Cannot load texture from empty filename" << std::endl; | |
| return this->CreateBuffer(); | |
| } | |
| FREE_IMAGE_FORMAT format = FreeImage_GetFileType(_filename.c_str(), 0); | |
| FIBITMAP *image = FreeImage_Load(format, _filename.c_str()); | |
| if (!image) | |
| { | |
| gzerr << "Unable to load texture: " << _filename << std::endl; | |
| return this->CreateBuffer(); | |
| } | |
| FIBITMAP *temp = image; | |
| image = FreeImage_ConvertTo32Bits(image); | |
| unsigned w = FreeImage_GetWidth(image); | |
| unsigned h = FreeImage_GetHeight(image); | |
| // freeimage stores data as BGR[A] on little endian architecture | |
| // reverse pixel values if needed | |
| #if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_BGR | |
| unsigned p = FreeImage_GetPitch(image); | |
| unsigned bpp = FreeImage_GetBPP(image) / 8; | |
| unsigned lineSize = FreeImage_GetLine(image); | |
| BYTE* line = FreeImage_GetBits(image); | |
| for (unsigned y = 0; y < h; ++y, line += p) | |
| { | |
| for (BYTE* pixel = line; pixel < line + lineSize; pixel += bpp) | |
| { | |
| // in- place swap | |
| pixel[0] ^= pixel[2]; pixel[2] ^= pixel[0]; pixel[0] ^= pixel[2]; | |
| } | |
| } | |
| #endif | |
| FreeImage_Unload(temp); | |
| optix::Context optixContext = this->scene->OptixContext(); | |
| optix::Buffer buffer = optixContext->createBuffer(RT_BUFFER_INPUT); | |
| buffer->setFormat(RT_FORMAT_UNSIGNED_BYTE4); | |
| buffer->setSize(w, h); | |
| // get raw bits after flipping vertical axis (last bool arg) | |
| // as free image stores data upside down in memory | |
| FreeImage_ConvertToRawBits(reinterpret_cast<BYTE *>(buffer->map()), | |
| image, FreeImage_GetLine(image), FreeImage_GetBPP(image), | |
| FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, true); | |
| buffer->unmap(); | |
| FreeImage_Unload(image); | |
| return buffer; | |
| } |
so it should be relatively straightforward to replace freeimage which supports a bunch of other image formats.
Here is a list of all of the known unfixed vulnerabilities in freeimage:
- CVE-2019-12212
- CVE-2019-12214
- CVE-2020-21426
- CVE-2020-21427
- CVE-2020-21428
- CVE-2020-22524
- CVE-2020-24292
- CVE-2020-24293
- CVE-2020-24294
- CVE-2020-24295
- CVE-2021-33367
- CVE-2021-40262
- CVE-2021-40263
- CVE-2021-40264
- CVE-2021-40265
- CVE-2021-40266
- CVE-2023-47992
- CVE-2023-47993
- CVE-2023-47994
- CVE-2023-47995
- CVE-2023-47996
- CVE-2023-47997
- CVE-2024-28562
- CVE-2024-28563
- CVE-2024-28564
- CVE-2024-28565
- CVE-2024-28566
- CVE-2024-28567
- CVE-2024-28568
- CVE-2024-28569
- CVE-2024-28570
- CVE-2024-28571
- CVE-2024-28572
- CVE-2024-28573
- CVE-2024-28574
- CVE-2024-28575
- CVE-2024-28576
- CVE-2024-28577
- CVE-2024-28578
- CVE-2024-28579
- CVE-2024-28580
- CVE-2024-28581
- CVE-2024-28582
- CVE-2024-28583
- CVE-2024-28584
- CVE-2024-31570
- CVE-2024-9029
- CVE-2025-65803
- CVE-2025-70968
in order to replace freeimage, you'd want to find some other library that supports a bunch of similar formats to the ones freeimage supports.
freeimage supports the following file formats:
- bmp
- ico
- jpeg
- jng
- koala
- lbm/iff
- mng
- pbm/pbmraw
- pcd
- pcx
- pgm/pgmraw
- png
- ppm/ppmraw
- ras
- targa
- tiff
- wbmp
- psd
- cut
- xbm
- xpm
- dds
- gif
- hdr
- faxg3
- sgi
- exr
- j2k
- jp2
- pfm
- pict
- raw
- webp
- jxf
one option would be to use opencv, which supports the following file formats:
- bmp
- ico
- jpeg
- jng
- koala
- lbm/iff
- mng
- pbm/pbmraw
- pcd
- pcx
- pgm/pgmraw
- png
- ppm/ppmraw
- ras
- targa
- tiff
- wbmp
- psd
- cut
- xbm
- xpm
- dds
- gif
- hdr
- faxg3
- sgi
- exr
- j2k
- jp2
- pfm
- pict
- raw
- webp
- jxf
as well as several niche formats that are not supported by freeimage.
out of the formats which are not supported by opencv, they seem to be extremely niche, and are likely very seldom used.
alternatively, another library which supports all those formats could be found.
related: gazebosim/gz-common#388 (didn't see this issue until afterwards, oopsies)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status