diff --git a/tasmota/xdrv_50_filesystem.ino b/tasmota/xdrv_50_filesystem.ino index a7000c6b4..828028827 100644 --- a/tasmota/xdrv_50_filesystem.ino +++ b/tasmota/xdrv_50_filesystem.ino @@ -348,6 +348,11 @@ bool TfsLoadFile(const char *fname, uint8_t *buf, uint32_t len) { AddLog(LOG_LEVEL_INFO, PSTR("TFS: File '%s' not found"), fname +1); // Skip leading slash return false; } + + size_t flen = file.size(); + if (len > flen){ + len = flen; + } file.read(buf, len); file.close();