mirror of
https://github.com/pi-hole/FTL.git
synced 2025-12-20 03:58:30 +00:00
Use memcpy instead of strncpy in cases where we want to use only parts of strings. GCC 8.1 and higher warns about using strncpy when it detects possible truncations already at compile time.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
2
api.c
2
api.c
@@ -972,7 +972,7 @@ void getVersion(const int *sock)
|
||||
|
||||
// Extract first 7 characters of the hash
|
||||
char hash[8];
|
||||
strncpy(hash, commit, 7); hash[7] = 0;
|
||||
memcpy(hash, commit, 7); hash[7] = 0;
|
||||
|
||||
if(strlen(tag) > 1) {
|
||||
if(istelnet[*sock])
|
||||
|
||||
2
args.c
2
args.c
@@ -62,7 +62,7 @@ void parse_args(int argc, char* argv[])
|
||||
const char * commit = GIT_HASH;
|
||||
char hash[8];
|
||||
// Extract first 7 characters of the hash
|
||||
strncpy(hash, commit, 7); hash[7] = 0;
|
||||
memcpy(hash, commit, 7); hash[7] = 0;
|
||||
printf("vDev-%s\n", hash);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
4
shmem.c
4
shmem.c
@@ -86,8 +86,8 @@ size_t addstr(const char *str)
|
||||
counters->strings_MAX = shm_strings.size;
|
||||
|
||||
// Copy the C string pointed by str into the shared string buffer
|
||||
strncpy(&((char*)shm_strings.ptr)[shmSettings->next_str_pos], str, len);
|
||||
((char*)shm_strings.ptr)[shmSettings->next_str_pos + len] = '\0';
|
||||
// the length (len+1) ensures that we copy the terminator as well
|
||||
strncpy(&((char*)shm_strings.ptr)[shmSettings->next_str_pos], str, len + 1);
|
||||
|
||||
// Increment string length counter
|
||||
shmSettings->next_str_pos += len+1;
|
||||
|
||||
Reference in New Issue
Block a user