38 lines
1.4 KiB
Diff
38 lines
1.4 KiB
Diff
From 8adbe9aacb93c5a160f3ecfc00adc10a64d27c14 Mon Sep 17 00:00:00 2001
|
|
From: Sekhar Nori <nsekhar@ti.com>
|
|
Date: Tue, 19 Feb 2019 08:29:58 +0000
|
|
Subject: [PATCH 108/112] Fix string truncation issues detected by GCC 8
|
|
|
|
This fixes string truncation warning generated by GCC of the form:
|
|
|
|
irqbalance.c:485:2: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
|
|
strncpy(addr.sun_path, socket_name, strlen(socket_name));
|
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Using source size in strncpy so fix that by using destination size.
|
|
For the instance of this issue in irqbalance-ui.c, fix the issue by
|
|
eliminating the unneeded temporary buffer.
|
|
|
|
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
|
|
---
|
|
irqbalance.c | 2 +-
|
|
ui/irqbalance-ui.c | 5 ++---
|
|
2 files changed, 3 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/irqbalance.c b/irqbalance.c
|
|
index 60d8a5e..c1a0e15 100644
|
|
--- a/irqbalance.c
|
|
+++ b/irqbalance.c
|
|
@@ -482,7 +482,7 @@ int init_socket()
|
|
*/
|
|
addr.sun_family = AF_UNIX;
|
|
snprintf(socket_name, 64, "%s/%s%d.sock", SOCKET_TMPFS, SOCKET_PATH, getpid());
|
|
- strncpy(addr.sun_path, socket_name, strlen(socket_name));
|
|
+ strncpy(addr.sun_path, socket_name, sizeof(addr.sun_path));
|
|
if (bind(socket_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
|
|
log(TO_ALL, LOG_WARNING, "Daemon couldn't be bound to the file-based socket.\n");
|
|
|
|
--
|
|
1.8.3.1
|
|
|