1
0
Fork 0

Avoid buffer underflow by copying all fields

This code made silent assumption that first fields in direntry are
exactly 14 bytes - this was fine, except would break as soon as anyone
would touch the struct (or e.g. if a compiler would lack support for
packed structures and inject some padding in there); rewrite the copy
code to follow the same pattern as other fields - now the code will be
fine even if someone will change fields in the direntry struct.

Fixes 2 PVS static analysis issues (buffer underflow on src and dst).
This commit is contained in:
Patryk Obara 2020-02-23 00:41:33 +01:00
parent 6011c016c5
commit c619445003
2 changed files with 16 additions and 9 deletions

View file

@ -127,6 +127,10 @@ static INLINE void host_writed(HostPt off,Bit32u val) {
//
// __builtin_bswap* is supported since GCC 4.3 and Clang 3.4
constexpr static INLINE uint8_t host_to_le(uint8_t val) {
return val;
}
#if defined(WORDS_BIGENDIAN)
constexpr static INLINE int16_t host_to_le(int16_t val) {