1
0
Fork 0

Fix unsafe memory operations and warnings in the fatDrive class

- Move imageDiskList from pointer to vector of unique_ptr
- Replace string operations with size-limited versions
- Initialize members
- Eliminate unecessary casts
- Eliminate memory-leak on pointer assignment
This commit is contained in:
krcroft 2019-12-07 11:55:38 -08:00 committed by Patryk Obara
parent e942a02fcb
commit c9198b2944
11 changed files with 219 additions and 131 deletions

View file

@ -55,6 +55,13 @@ char * safe_strcpy(char (& dst)[N], const char * src) noexcept {
return & dst[0];
}
template<size_t N>
char * safe_strcat(char (& dst)[N], const char * src) noexcept {
const size_t dst_size = sizeof(dst);
strncat(dst, src, dst_size - strnlen(dst, dst_size) - 1);
return & dst[0];
}
#define safe_strncpy(a,b,n) do { strncpy((a),(b),(n)-1); (a)[(n)-1] = 0; } while (0)
#ifdef HAVE_STRINGS_H