Fix usage of strncat

This commit is contained in:
Andreas Eversberg
2024-01-04 17:58:05 +01:00
parent 454086f04c
commit 31d5667516
2 changed files with 3 additions and 3 deletions

View File

@@ -467,7 +467,7 @@ static void *device_child(void *arg)
const char *dev_info_argv[] = { dev_name };
struct cuse_info ci;
strncat(dev_name, device->name, sizeof(dev_name) - strlen(device->name) - 1);
strncat(dev_name, device->name, sizeof(dev_name) - strlen(dev_name) - 1);
memset(&ci, 0, sizeof(ci));
ci.dev_major = device->major;
@@ -520,7 +520,7 @@ void *device_init(void *inst, const char *name, int (*open)(void *inst, int flag
}
pthread_getname_np(device->thread, tname, sizeof(tname));
strncat(tname, "-device", sizeof(tname) - 7 - 1);
strncat(tname, "-device", sizeof(tname) - strlen(tname) - 1);
tname[sizeof(tname) - 1] = '\0';
pthread_setname_np(device->thread, tname);

View File

@@ -144,7 +144,7 @@ void set_speech_string(jolly_t *jolly, char announcement, const char *number)
{
jolly->speech_string[0] = announcement;
jolly->speech_string[1] = '\0';
strncat(jolly->speech_string, number, sizeof(jolly->speech_string) - strlen(number) - 1);
strncat(jolly->speech_string, number, sizeof(jolly->speech_string) - strlen(jolly->speech_string) - 1);
jolly->speech_digit = 0;
jolly->speech_pos = 0;
}