strukturag / libheif

libheif is an HEIF and AVIF file format decoder and encoder.
Other
1.7k stars 298 forks source link

compiler warnings on 32-bit environment #847

Open freakout42 opened 1 year ago

freakout42 commented 1 year ago
[  2%] Building CXX object libheif/CMakeFiles/heif.dir/bitstream.cc.o
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/bitstream.cc: In constructor 'StreamReader_memory::StreamReader_memory(const uint8_t*, int64_t, bool)':
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/bitstream.cc:75:32: warning: conversion from 'int64_t' {aka 'long long int'} to 'size_t' {aka 'unsigned int'} may change value [-Wconversion]
   75 |     memcpy(m_owned_data, data, m_length);
      |                                ^~~~~~~~

/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/bitstream.cc: In member function 'bool BitstreamRange::read(uint8_t*, int64_t)':
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/bitstream.cc:269:35: warning: conversion from 'int64_t' {aka 'long long int'} to 'size_t' {aka 'unsigned int'} may change value [-Wconversion]
  269 |   bool success = istr->read(data, n);
      |                                   ^
[  4%] Building CXX object libheif/CMakeFiles/heif.dir/box.cc.o

/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/box.cc: In member function 'virtual Error Box_colr::parse(BitstreamRange&)':
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/box.cc:1879:34: warning: conversion from 'long long unsigned int' to 'std::vector::size_type' {aka 'unsigned int'} may change value [-Wconversion]
 1879 |     std::vector rawData(profile_size);
      |                                  ^~~~~~~~~~~~

/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/box.cc: In member function 'virtual Error Box_av1C::parse(BitstreamRange&)':
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/box.cc:3313:24: warning: conversion from 'int64_t' {aka 'long long int'} to 'std::vector::size_type' {aka 'unsigned int'} may change value [-Wconversion]
 3313 |   m_config_OBUs.resize(configOBUs_bytes);
      |                        ^~~~~~~~~~~~~~~~
farindk commented 1 year ago

Do the above changes fix this?

freakout42 commented 1 year ago

now:

[  2%] Building CXX object libheif/CMakeFiles/heif.dir/bitstream.cc.o
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/bitstream.cc: In constructor 'StreamReader_memory::StreamReader_memory(const uint8_t*, size_t, bool)':
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/bitstream.cc:75:32: warning: conversion from 'int64_t' {aka 'long long int'} to 'size_t' {aka 'unsigned int'} may change value [-Wconversion]
   75 |     memcpy(m_owned_data, data, m_length);
      |                                ^~~~~~~~
[  4%] Building CXX object libheif/CMakeFiles/heif.dir/box.cc.o
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/box.cc: In member function 'virtual Error Box::parse(BitstreamRange&)':
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/box.cc:374:28: warning: conversion from 'uint64_t' {aka 'long long unsigned int'} to 'size_t' {aka 'unsigned int'} may change value [-Wconversion]
  374 |     if (range.prepare_read(content_size)) {
      |                            ^~~~~~~~~~~~
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/box.cc: In static member function 'static Error Box::read(BitstreamRange&, std::shared_ptr*)':
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/box.cc:587:67: warning: conversion from 'uint64_t' {aka 'long long unsigned int'} to 'size_t' {aka 'unsigned int'} may change value [-Wconversion]
  587 |   auto status = range.wait_for_available_bytes(hdr.get_box_size() - hdr.get_header_size());
      |                                                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/box.cc:616:27: warning: conversion from 'int64_t' {aka 'long long int'} to 'size_t' {aka 'unsigned int'} may change value [-Wconversion]
  616 |                           box_size_without_header,
      |                           ^~~~~~~~~~~~~~~~~~~~~~~
[  6%] Building CXX object libheif/CMakeFiles/heif.dir/error.cc.o
[  9%] Building CXX object libheif/CMakeFiles/heif.dir/heif.cc.o
[ 11%] Building CXX object libheif/CMakeFiles/heif.dir/context.cc.o
[ 13%] Building CXX object libheif/CMakeFiles/heif.dir/file.cc.o
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/file.cc: In member function 'Error HeifFile::read(const std::shared_ptr&)':
/home/axel/p/rpm/BUILD/libheif-1.16.1/libheif/file.cc:99:40: warning: conversion from 'uint64_t' {aka 'long long unsigned int'} to 'size_t' {aka 'unsigned int'} may change value [-Wconversion]
   99 |   BitstreamRange range(m_input_stream, maxSize);
      |                                        ^~~~~~~
[ 15%] Building CXX object libheif/CMakeFiles/heif.dir/pixelimage.cc.o
farindk commented 1 year ago

What environment and compiler are you using? I want to reproduce it here.

freakout42 commented 1 year ago

Hmm - very old environment - you will not invest in setup this: Red Hat Enterprise Linux AS release 3 Taroon glibc-2.3.2-95.33 gcc4 (GCC) 12.2.0 I use this environment to build rpms which run almost everywhere and indeed are very robust against attacks because no exploit is build for this binary - in almost 20 years running a bunch of servers using these rpms I had never a successful attack. I would understand if you refuse to support this - but I think any 32-bit environment will show these warnings.

farindk commented 1 year ago

I see. I thought it may be ARMv7, mobile or old RPi.

kmilos commented 2 months ago

Should be (partly?) addressed by https://github.com/strukturag/libheif/commit/66bdcdcdedf5100e04b52a95afd317addd23f2f3