From 1b80c00658044627e4a77a8d26d3b7bd362d36f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Sun, 3 Dec 2017 23:05:22 +0100 Subject: [PATCH] Fix overflow bug when comparing strings --- src/kernel/include/ttest.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kernel/include/ttest.h b/src/kernel/include/ttest.h index c101a0b..79a9df8 100644 --- a/src/kernel/include/ttest.h +++ b/src/kernel/include/ttest.h @@ -41,8 +41,8 @@ extern tt_test tt_tests[]; #define ASSERT_STRN(lhs, rhs, n) do { \ size_t tt_n = (size_t)(n); \ - char *tt_lhs = malloc(tt_n); \ - char *tt_rhs = malloc(tt_n); \ + char *tt_lhs = malloc(tt_n+1); \ + char *tt_rhs = malloc(tt_n+1); \ memcpy(tt_lhs, (lhs), tt_n); \ memcpy(tt_rhs, (rhs), tt_n); \ tt_rhs[tt_n] = tt_lhs[tt_n] = '\0'; \