Skip to content

Commit 2c41562

Browse files
authored
Fix logical error in path validation for SD file handling (#1113)
* Fix logical error in path validation for SD file handling * Fix logical error in path validation for SPIFFS file handling
1 parent cee8abb commit 2c41562

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

esp3d/src/modules/http/handlers/handle-SD-files.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void HTTP_Server::handleSDFileList() {
100100
status = shortname + " deleted";
101101
// what happen if no "/." and no other subfiles for SPIFFS like?
102102
String ptmp = path;
103-
if ((path != "/") && (path[path.length() - 1] = '/')) {
103+
if ((path != "/") && (path[path.length() - 1] == '/')) {
104104
ptmp = path.substring(0, path.length() - 1);
105105
}
106106
if (!ESP_SD::exists(ptmp.c_str())) {
@@ -160,7 +160,7 @@ void HTTP_Server::handleSDFileList() {
160160
buffer2send.reserve(1200);
161161
buffer2send = "{\"files\":[";
162162
String ptmp = path;
163-
if ((path != "/") && (path[path.length() - 1] = '/')) {
163+
if ((path != "/") && (path[path.length() - 1] == '/')) {
164164
ptmp = path.substring(0, path.length() - 1);
165165
}
166166
_webserver->setContentLength(CONTENT_LENGTH_UNKNOWN);

esp3d/src/modules/http/handlers/handle-files.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void HTTP_Server::handleFSFileList() {
8888
status = shortname + " deleted";
8989
// what happen if no "/." and no other subfiles for SPIFFS like?
9090
String ptmp = path;
91-
if ((path != "/") && (path[path.length() - 1] = '/')) {
91+
if ((path != "/") && (path[path.length() - 1] == '/')) {
9292
ptmp = path.substring(0, path.length() - 1);
9393
}
9494
if (!ESP_FileSystem::exists(ptmp.c_str())) {
@@ -144,7 +144,7 @@ void HTTP_Server::handleFSFileList() {
144144
buffer2send.reserve(1200);
145145
buffer2send = "{\"files\":[";
146146
String ptmp = path;
147-
if ((path != "/") && (path[path.length() - 1] = '/')) {
147+
if ((path != "/") && (path[path.length() - 1] == '/')) {
148148
ptmp = path.substring(0, path.length() - 1);
149149
}
150150
_webserver->setContentLength(CONTENT_LENGTH_UNKNOWN);

0 commit comments

Comments
 (0)