From ec7ff74a979f68c48954487c3a0bf335dcc6359c Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Tue, 2 Dec 2014 18:12:51 -0700 Subject: loader: Fix missing terminator on string strncpy does not copy the terminating null character so were getting invalid directory names. Since we know there is enough space for the string, just copy it and get the terminator as well. --- loader/loader.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'loader') diff --git a/loader/loader.c b/loader/loader.c index dcdc5fa1..6cb7b136 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -412,7 +412,11 @@ static void layer_lib_scan(const char * libInPaths) return; } loader.layer_dirs = malloc(len+1); - strncpy(loader.layer_dirs, p, len); + if (loader.layer_dirs == NULL) + return; + + // Alloc passed, so we know there is enough space to hold the string, don't need strncpy + strcpy(loader.layer_dirs, p); libPaths = loader.layer_dirs; /* cleanup any previously scanned libraries */ -- cgit v1.2.3