Skip to content

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

Open

Description

@mdh1418

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.

Activity

  1. kripken commented on Aug 31, 2020

    @kripken
    Member

    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...

  2. akoeplinger commented on Sep 1, 2020

    @akoeplinger
    Contributor

    The limitation probably comes from

    #define NAME_MAX 255

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

  3. mdh1418 commented on Sep 1, 2020

    @mdh1418
    ContributorAuthor

    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.

  4. akoeplinger commented on Sep 1, 2020

    @akoeplinger
    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.

  5. akoeplinger commented on Sep 1, 2020

    @akoeplinger
    Contributor

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

  6. akoeplinger commented on Sep 1, 2020

    @akoeplinger
    Contributor

    so most likely here:

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

  7. stale commented on Sep 3, 2021

    @stale

    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.

  8. akoeplinger commented on Sep 3, 2021

    @akoeplinger
    Contributor

    From what I can see this is still an issue.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions