aom_thread: quiet -Wstringop-truncation
pass sizeof - 1 to strncpy rather than sizeof. though the final byte is
explicitly zeroed -- one recommended mitigation for this pattern [1] --
in some configurations (-fsanitize=address) the warning will still be
emitted.
[1] https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/
cf., Mitigating strncpy Truncation
Change-Id: I939bb16d23da2082aebfe7c08f89666a90141482
diff --git a/aom_util/aom_thread.c b/aom_util/aom_thread.c
index 244ac3b..a749a22 100644
--- a/aom_util/aom_thread.c
+++ b/aom_util/aom_thread.c
@@ -48,7 +48,7 @@
// thread_name is too long, pthread_setname_np returns -1 with errno
// ENAMETOOLONG (63).
char thread_name[64];
- strncpy(thread_name, worker->thread_name, sizeof(thread_name));
+ strncpy(thread_name, worker->thread_name, sizeof(thread_name) - 1);
thread_name[sizeof(thread_name) - 1] = '\0';
pthread_setname_np(thread_name);
}
@@ -57,7 +57,7 @@
// Linux and Android require names (with nul) fit in 16 chars, otherwise
// pthread_setname_np() returns ERANGE (34).
char thread_name[16];
- strncpy(thread_name, worker->thread_name, sizeof(thread_name));
+ strncpy(thread_name, worker->thread_name, sizeof(thread_name) - 1);
thread_name[sizeof(thread_name) - 1] = '\0';
pthread_setname_np(pthread_self(), thread_name);
}