rockchip-linux / rkdeveloptool

GNU General Public License v2.0
165 stars 96 forks source link

format truncation compile error #55

Open markg85 opened 3 years ago

markg85 commented 3 years ago
g++ -DHAVE_CONFIG_H -I. -I./cfg  -Wall -Werror -Wextra -Wreturn-type -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -I/usr/include/libusb-1.0    -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.cpp
main.cpp: In function ‘bool _Z9mergeBootv.part.0()’:
main.cpp:1493:36: error: ‘%s’ directive output may be truncated writing up to 557 bytes into a region of size 5 [-Werror=format-truncation=]
 1493 |  snprintf(buffer, sizeof(buffer), "%s", chip);
      |                                    ^~
......
 1534 |   chipType = convertChipType(chip + 2);
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:1493:10: note: ‘snprintf’ output between 1 and 558 bytes into a destination of size 5
 1493 |  snprintf(buffer, sizeof(buffer), "%s", chip);
      |  ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[1]: *** [Makefile:491: main.o] Error 1
make[1]: Leaving directory '/home/mark/pkgbuilds/rkdeveloptool'
make: *** [Makefile:511: all-recursive] Error 1

Any fix for this?

MrMEEE commented 3 years ago

Same issue here

MrMEEE commented 3 years ago

If you insert "-Wno-format-truncation" at line 356:

AM_CPPFLAGS = -Wall -Wno-format-truncation -Werror -Wextra -Wreturn-type -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE $(LIBUSB1_CFLAGS)

It works for me...

mrespin commented 3 years ago

Edit the main.cpp line 1491 from static inline uint32_t convertChipType(const char chip) { char buffer[5]; memset(buffer, 0, sizeof(buffer)); to static inline uint32_t convertChipType(const char chip) { char buffer[558]; memset(buffer, 0, sizeof(buffer)); No more error.

markg85 commented 3 years ago

I'll leave this open as it's a bug. But for me it's a non-issue by now. That's mainly because i'm not developing for this anymore.

antoxic commented 2 years ago

Edit the main.cpp line 1491 from static inline uint32_t convertChipType(const char chip) { char buffer[5]; memset(buffer, 0, sizeof(buffer)); to static inline uint32_t convertChipType(const char chip) { char buffer[558]; memset(buffer, 0, sizeof(buffer)); No more error.

Yeah, it works thank you

phodina commented 2 years ago

Hi there are 2 PRs for this issue: https://github.com/rockchip-linux/rkdeveloptool/pull/63 https://github.com/rockchip-linux/rkdeveloptool/pull/62

develperbayman commented 1 year ago

i just wanna fix my orange pi 5 that i foolishly flashed all drives with the bootloader ......is there a prebuilt binary available for linux?

PeterAlfonsLoch commented 1 year ago

Edit the main.cpp line 1491 from static inline uint32_t convertChipType(const char chip) { char buffer[5]; memset(buffer, 0, sizeof(buffer)); to static inline uint32_t convertChipType(const char chip) { char buffer[558]; memset(buffer, 0, sizeof(buffer)); No more error.

I shouldn't be hard to just fix this in repo?

But there is a reason why SBC's are dying.... It is 2023 and the same issue persists.

serhii-nakon commented 1 year ago

Here fixed version of this tool https://github.com/radxa/rkdeveloptool/commits/master