Memory overrun and C++11 updates
- Limit write length into buffer, and add comment about corner-case - Use C++11's syntax to explicitly remove private copy and assignment operators - Use C++11 container loop syntax to shorting a cleanup function
This commit is contained in:
parent
959417f6de
commit
8c6758c8d1
3 changed files with 56 additions and 47 deletions
|
@ -51,8 +51,8 @@
|
|||
|
||||
template<size_t N>
|
||||
char * safe_strcpy(char (& dst)[N], const char * src) noexcept {
|
||||
snprintf(dst, N, "%s", src);
|
||||
return & dst[0];
|
||||
snprintf(dst, N, "%s", src);
|
||||
return & dst[0];
|
||||
}
|
||||
|
||||
#define safe_strncpy(a,b,n) do { strncpy((a),(b),(n)-1); (a)[(n)-1] = 0; } while (0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue