59 lines
1.8 KiB
Diff
59 lines
1.8 KiB
Diff
From d6abbe898baa111207e1e9316dde75c38d555325 Mon Sep 17 00:00:00 2001
|
|
From: Neil Horman <nhorman@tuxdriver.com>
|
|
Date: Mon, 9 Jul 2018 10:12:41 -0400
|
|
Subject: [PATCH 091/112] Fix some string copy limitations
|
|
|
|
Latest gcc caught some errors in our string copying routines. Fix those
|
|
up
|
|
|
|
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
|
|
---
|
|
irqbalance.c | 3 +--
|
|
procinterrupts.c | 2 +-
|
|
ui/irqbalance-ui.c | 2 +-
|
|
3 files changed, 3 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/irqbalance.c b/irqbalance.c
|
|
index 66e56f8..2614719 100644
|
|
--- a/irqbalance.c
|
|
+++ b/irqbalance.c
|
|
@@ -468,8 +468,7 @@ int init_socket(char *socket_name)
|
|
}
|
|
|
|
addr.sun_family = AF_UNIX;
|
|
- addr.sun_path[0] = '\0';
|
|
- strncpy(addr.sun_path + 1, socket_name, strlen(socket_name));
|
|
+ strncpy(addr.sun_path, socket_name, strlen(addr.sun_path));
|
|
if (bind(socket_fd, (struct sockaddr *)&addr,
|
|
sizeof(sa_family_t) + strlen(socket_name) + 1) < 0) {
|
|
log(TO_ALL, LOG_WARNING, "Daemon couldn't be bound to the socket.\n");
|
|
diff --git a/procinterrupts.c b/procinterrupts.c
|
|
index 4ef8751..7283998 100644
|
|
--- a/procinterrupts.c
|
|
+++ b/procinterrupts.c
|
|
@@ -274,7 +274,7 @@ void parse_proc_interrupts(void)
|
|
if (!c)
|
|
continue;
|
|
|
|
- strncpy(savedline, line, sizeof(savedline));
|
|
+ strncpy(savedline, line, sizeof(savedline)-1);
|
|
|
|
*c = 0;
|
|
c++;
|
|
diff --git a/ui/irqbalance-ui.c b/ui/irqbalance-ui.c
|
|
index 3fc46af..d4deee0 100644
|
|
--- a/ui/irqbalance-ui.c
|
|
+++ b/ui/irqbalance-ui.c
|
|
@@ -57,7 +57,7 @@ int init_connection()
|
|
addr.sun_family = AF_UNIX;
|
|
char socket_name[64];
|
|
snprintf(socket_name, 64, "%s%d.sock", SOCKET_PATH, irqbalance_pid);
|
|
- strncpy(addr.sun_path + 1, socket_name, strlen(socket_name));
|
|
+ strncpy(addr.sun_path, socket_name, strlen(addr.sun_path));
|
|
|
|
if(connect(socket_fd, (struct sockaddr *)&addr,
|
|
sizeof(sa_family_t) + strlen(socket_name) + 1) < 0) {
|
|
--
|
|
1.8.3.1
|
|
|