From 16cb6df56960f58df61ec35ef3be45286eb3c788 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Sun, 2 Sep 2018 23:40:45 +0800 Subject: [PATCH 2/4] Fix an possible overflow error Got: "specified bound 2048 exceeds the size 19 of the destination" when -O2 is used, and a "*** buffer overflow detected ***" error output with no backtrace. With -O0, it's gone, guess it's some gcc optimization problem, and the size there is wrong anyway, this patch could fix it. --- irqbalance.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/irqbalance.c b/irqbalance.c index 4b3de54..c89c3c0 100644 --- a/irqbalance.c +++ b/irqbalance.c @@ -457,8 +457,8 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri } if (!strncmp(buff, "setup", strlen("setup"))) { char banned[512]; - char *setup = calloc(strlen("SLEEP ") + 11 +1, 1); - snprintf(setup, 2048, "SLEEP %d ", sleep_interval); + char *setup = calloc(strlen("SLEEP ") + 11 + 1, 1); + snprintf(setup, strlen("SLEEP ") + 11 + 1, "SLEEP %d ", sleep_interval); if(g_list_length(cl_banned_irqs) > 0) { for_each_irq(cl_banned_irqs, get_irq_data, setup); } -- 2.17.1