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

exception not thrown when truncating filenames longer than 255 char #12076

Open
mdh1418 opened this issue Aug 28, 2020 · 8 comments
Open

exception not thrown when truncating filenames longer than 255 char #12076

mdh1418 opened this issue Aug 28, 2020 · 8 comments

Comments

@mdh1418
Copy link
Contributor

mdh1418 commented Aug 28, 2020

When files with a filename greater than 255 characters is being created, it is truncated, but does not throw an exception that other systems throw.

Expectation: File is truncated and created with an exception thrown.

@kripken
Copy link
Member

kripken commented Aug 31, 2020

Interesting, I don't remember us imposing a 255 character limit anywhere. But maybe it's a part of library_fs.js I'm not familiar with? It should be in there or maybe in library_path.js.

edit: Oh, hmm, unless it's a musl limitation and it happens there...

@akoeplinger
Copy link
Contributor

The limitation probably comes from

#define NAME_MAX 255

However it's not clear to me where exactly the truncation happens.

@mdh1418
Copy link
Contributor Author

mdh1418 commented Sep 1, 2020

I looked to make a repro yesterday but didn't manage to make one demonstrating opening a file with a path basename longer than 255 characters. I suspected that the truncation happens here within the open: function which is the one I believe is called into through the pal code.

FS.truncate(node, 0);
but when I tried to repro, it doesn't hit that logic because of this.
if (FS.isChrdev(node.mode)) {
.

I also thought NAME_MAX was being used, but after grepping through files in this repo, its not obvious to me how the variable contributes to truncation.

@akoeplinger
Copy link
Contributor

hm no, that first library_fs.js just truncated the file contents, not the name.

I think what probably happens is that when we create the inode we don't check for the length before filling this struct:

struct inode {
char name[NAME_MAX + 1]; // NAME_MAX actual bytes + one byte for null termination.

@akoeplinger
Copy link
Contributor

ah, I just read that asmfs is a work in progress so it's probably not that: #9534 😄

@akoeplinger
Copy link
Contributor

so most likely here:

// generic function for all node creation
mknod: function(path, mode, dev) {

@stale
Copy link

stale bot commented Sep 3, 2021

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Sep 3, 2021
@akoeplinger
Copy link
Contributor

From what I can see this is still an issue.

@stale stale bot removed the wontfix label Sep 3, 2021
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

3 participants