From 206397282c3adbdcbc6a163d6692588d214e62ed Mon Sep 17 00:00:00 2001 From: Manikandan C Date: Mon, 4 Jul 2016 17:09:27 +0530 Subject: dlt-system-filetransfer: fix bug caused by malloc assert Remove malloc assert in inappropriate location and add error logs in case of failures. Signed-off-by: Manikandan C --- src/system/dlt-system-filetransfer.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/system/dlt-system-filetransfer.c b/src/system/dlt-system-filetransfer.c index 7bc1671..819b6de 100644 --- a/src/system/dlt-system-filetransfer.c +++ b/src/system/dlt-system-filetransfer.c @@ -257,6 +257,13 @@ int send_one(char *src, FiletransferOptions const *opts, int which) // Prepare all needed file names char *fn = basename(src); + if (fn == NULL) + { + DLT_LOG(dltsystem, + DLT_LOG_ERROR, + DLT_STRING("basename not valid")); + return -1; + } char *fdir = strndup(src,PATH_MAX); MALLOC_ASSERT(fdir); @@ -265,16 +272,14 @@ int send_one(char *src, FiletransferOptions const *opts, int which) char *rn = unique_name(src);//new unique filename based on inode - if(rn == NULL) + if (rn == NULL) { - // unique name couldn't be generated - // (usually because the file could not be found because it has - // already been sent by a previous change/move of the same file) + DLT_LOG(dltsystem, + DLT_LOG_ERROR, + DLT_STRING("file information not available, may be file got overwritten")); return -1; } - MALLOC_ASSERT(fn); - // Compress if needed if(opts->Compression[which] > 0) { -- cgit v1.2.1