From c49bf47e0864d6aa428054ec837c9e3b71dca1ea Mon Sep 17 00:00:00 2001 From: Kever Yang Date: Fri, 28 Jun 2019 12:50:06 +0800 Subject: [PATCH] fix array boundry error 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 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -c -o main.o main.cpp main.cpp: In function 'bool unpackBoot(char*)': main.cpp:1734:11: error: array subscript 20 is outside array bounds of 'char [20]' [-Werror=array-bounds]1734 | str[len] = 0;| ~~~~~~~~~^~~ main.cpp:1772:7: note: while referencing 'name'1772 | char name[MAX_NAME_LEN];| ^~~~ cc1plus: all warnings being treated as errors make[1]: *** [Makefile:475: main.o] Error 1 Reported-by: Peter Robinson Signed-off-by: Kever Yang --- main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/main.cpp b/main.cpp index 8431c98..956e0ca 100644 --- a/main.cpp +++ b/main.cpp @@ -1730,7 +1730,6 @@ static inline void wide2str(const uint16_t* wide, char* str, int len) for (i = 0; i < len; i++) { str[i] = (char) (wide[i] & 0xFF); } - str[len] = 0; } static bool unpackEntry(rk_boot_entry* entry, const char* name,