libdev.a

C Helper library
Log | Files | Refs | README | LICENSE | git clone https://git.ne02ptzero.me/git/libdev.a

commit 5f77ca5c6884e78d6f2fd41bdd94b22e7933bc3a
parent 2b9548cca33bfb1cdc4e61e6fd8a6bed46055782
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Thu, 13 Oct 2016 14:34:56 +0200

Fix(Write out-of-bounds):

Change strcpy to memcpy.
Small fix in Makefile.

Diffstat:
MMakefile | 2+-
Mtests.c | 6++++--
2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -13,7 +13,7 @@ $(NAME): $(OBJS) $(LIB) $(LFLAGS) $(NAME).a $(OBJS) test: $(NAME) - cd tests && make + cd tests && make re clean: rm -f $(OBJS) diff --git a/tests.c b/tests.c @@ -22,10 +22,12 @@ void register_test(char *group, char *(*fn_test)(void), char *name) { ptr->group = malloc(strlen(group)); ptr->name = malloc(strlen(name)); L_ASSERT(ptr->group && ptr->name); - strcpy(ptr->group, group); - strcpy(ptr->name, name); + memcpy(ptr->group, group, strlen(group)); + memcpy(ptr->name, name, strlen(name)); + L_ASSERT(ptr->group && ptr->name); ptr->fn_test = fn_test; list_add(tests, ptr, sizeof(t_test)); + free(ptr); singleton_lists(TESTS_LIST, tests); }