Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format truncation compile error #55

Open
markg85 opened this issue May 25, 2021 · 9 comments · May be fixed by #57
Open

format truncation compile error #55

markg85 opened this issue May 25, 2021 · 9 comments · May be fixed by #57

Comments

@markg85
Copy link

markg85 commented May 25, 2021

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
Copy link

MrMEEE commented Jun 17, 2021

Same issue here

@MrMEEE
Copy link

MrMEEE commented Jun 17, 2021

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
Copy link

mrespin commented Sep 19, 2021

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
Copy link
Author

markg85 commented Sep 19, 2021

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
Copy link

antoxic commented Feb 23, 2022

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
Copy link

phodina commented Mar 18, 2022

Hi there are 2 PRs for this issue:
#63
#62

@develperbayman
Copy link

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
Copy link

PeterAlfonsLoch commented Jun 16, 2023

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants