added length check for paths of files to be transferred
authorSimon Brandner <simon.brandner@partner.bmw.de>
Mon, 18 Mar 2013 12:52:42 +0000 (13:52 +0100)
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Fri, 19 Jul 2013 14:54:42 +0000 (16:54 +0200)
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
src/system/dlt-system-filetransfer.c

index d33e6b9..b75f614 100644 (file)
@@ -663,6 +663,12 @@ int wait_for_files(FiletransferOptions const *opts)
                     {
                         DLT_LOG(dltsystem, DLT_LOG_DEBUG, DLT_STRING("dlt-system-filetransfer, found new file."));
                         int length = strlen(opts->Directory[j])+ie->len+1;
+                        if (length > PATH_MAX)
+                        {
+                            DLT_LOG(filetransferContext, DLT_LOG_ERROR,
+                                    DLT_STRING("dlt-system-filetransfer: Very long path for file transfer. Cancelling transfer! Length is: "),DLT_INT(length));
+                            return -1;
+                        }
                         char *tosend = malloc(length);
                         snprintf(tosend,length, "%s/%s", opts->Directory[j], ie->name);
                         send_one(tosend, opts, j);