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 <pbrobinson@gmail.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
This commit is contained in:
Kever Yang 2019-06-28 12:50:06 +08:00 committed by Caesar Wang
parent 5e44dcd9e7
commit c49bf47e08

View File

@ -1730,7 +1730,6 @@ static inline void wide2str(const uint16_t* wide, char* str, int len)
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
str[i] = (char) (wide[i] & 0xFF); str[i] = (char) (wide[i] & 0xFF);
} }
str[len] = 0;
} }
static bool unpackEntry(rk_boot_entry* entry, const char* name, static bool unpackEntry(rk_boot_entry* entry, const char* name,