From 6b3524b6a6070c8f3d3147263c48c6d8de04d67a Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Sat, 17 Nov 2012 15:36:00 +0200 Subject: [PATCH] fix potential access of NULL pointer It could happen if delimiter is NULL. Currently the only use is with non-NULL delimiter. --- common/catdup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/common/catdup.c b/common/catdup.c index 6733a499..396bb5b7 100644 --- a/common/catdup.c +++ b/common/catdup.c @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2009,2010 Nedko Arnaudov + * Copyright (C) 2009,2010,2012 Nedko Arnaudov * ************************************************************************** * This file contains implementation of the catdup() function @@ -185,8 +185,11 @@ char * catdup_array(const char ** array, const char * delimiter) len = strlen(array[i]); memcpy(p, array[i], len); p += len; - memcpy(p, delimiter, delimiter_length); - p += delimiter_length; + if (delimiter_length > 0) + { + memcpy(p, delimiter, delimiter_length); + p += delimiter_length; + } } *p = 0;