Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPIFFS filename length > 30, causes unexpected behaviour #1088

Closed
sticilface opened this issue Nov 27, 2015 · 1 comment
Closed

SPIFFS filename length > 30, causes unexpected behaviour #1088

sticilface opened this issue Nov 27, 2015 · 1 comment

Comments

@sticilface
Copy link
Contributor

Creating files of length greater than 31 causes extra characters to be appended to filename, which cannot then be deleted. (really it is 31, but the first / counts) shown below, is an example.

     FS File: /29aaaaaaaaaaaaaaaaaaaaaaaaaa, size: 31B
     FS File: /30aaaaaaaaaaaaaaaaaaaaaaaaaaa, size: 32B
     FS File: /31aaaaaaaaaaaaaaaaaaaaaaaaaaaa, size: 33B
     FS File: /32aaaaaaaaaaaaaaaaaaaaaaaaaaaaa. ", size: 34B
     FS File: /33aaaaaaaaaaaaaaaaaaaaaaaaaaaaa. #, size: 35B

Here is a gist that demonstrates the problem.
https://gist.github.com/sticilface/20c9973da4ccbe993c97
Warning it deletes all files on the device.

run the sketch, then run it again and you will see that the files 32 + 33, are not deleted.

proposal , adding length check to file.open()

File FS::open(const char* path, const char* mode) {
    if (!_impl) {
        return File();
    }

    OpenMode om;
    AccessMode am;
    if (!sflags(mode, om, am)) {
        DEBUGV("FS::open: invalid mode `%s`\r\n", mode);
        return File();
    }

    if (strlen(path) > 31) return File(); 

    return File(_impl->open(path, om, am));
}

I do realise that 32 is the max length, I just wanted to demonstrate, but it appears 31 is really the practical max length. If you accidentally make this it should fail and not create an un-deletable file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants