@@ -347,7 +347,7 @@ bool DiagnosticsService::requestDiagnosticsUpload(const char *location, unsigned
347347}
348348#endif // MO_ENABLE_V16
349349
350- MO_GetLogStatus DiagnosticsService::getLog (MO_LogType type, int requestId, int retries, unsigned int retryInterval, const char *remoteLocation , Timestamp oldestTimestamp, Timestamp latestTimestamp, char filenameOut[MO_GETLOG_FNAME_SIZE]) {
350+ MO_GetLogStatus DiagnosticsService::getLog (MO_LogType type, int requestId, int retries, unsigned int retryInterval, const char *location , Timestamp oldestTimestamp, Timestamp latestTimestamp, char filenameOut[MO_GETLOG_FNAME_SIZE]) {
351351
352352 if (runCustomUpload || this ->retries > 0 ) {
353353 MO_DBG_INFO (" upload still running" );
@@ -405,13 +405,21 @@ MO_GetLogStatus DiagnosticsService::getLog(MO_LogType type, int requestId, int r
405405
406406 MO_FREE (this ->location );
407407 this ->location = nullptr ;
408- size_t locationSize = strlen (location);
408+ size_t locationSize = strlen (location) + 1 ;
409409 this ->location = static_cast <char *>(MO_MALLOC (getMemoryTag (), locationSize));
410410 if (!this ->location ) {
411411 MO_DBG_ERR (" OOM" );
412412 goto fail;
413413 }
414414
415+ {
416+ int ret = snprintf (this ->location , locationSize, " %s" , location);
417+ if (ret < 0 || (size_t )ret >= locationSize) {
418+ MO_DBG_ERR (" snprintf: %i" , ret);
419+ goto fail;
420+ }
421+ }
422+
415423 MO_FREE (this ->filename );
416424 this ->filename = nullptr ;
417425
@@ -636,6 +644,7 @@ bool DiagnosticsService::uploadDiagnostics() {
636644 }
637645
638646 diagPreambleLen += (size_t )ret;
647+ ret = 0 ;
639648
640649 #if MO_ENABLE_V16
641650 if (ocppVersion == MO_OCPP_V16) {
@@ -654,8 +663,6 @@ bool DiagnosticsService::uploadDiagnostics() {
654663 auto availSvcEvse1 = availSvc ? availSvc->getEvse (1 ) : nullptr ;
655664 auto availSvcEvse2 = availSvc ? availSvc->getEvse (2 ) : nullptr ;
656665
657- ret = 0 ;
658-
659666 if (ret >= 0 && (size_t )ret + diagPostambleLen < MO_DIAG_POSTAMBLE_SIZE) {
660667 diagPostambleLen += (size_t )ret;
661668 ret = snprintf (diagPostamble + diagPostambleLen, MO_DIAG_POSTAMBLE_SIZE - diagPostambleLen,
@@ -923,7 +930,6 @@ bool DiagnosticsService::startFtpUpload() {
923930
924931 memcpy (buf + written, fileHeading, (size_t )writeLen);
925932 written += (size_t )writeLen;
926- filesystem->close (file);
927933 }
928934
929935 filesystem->seek (file, diagFilesBackTransferred);
0 commit comments