Thanks to visit codestin.com
Credit goes to github.com

Skip to content

stream names should be limited to 32 UTF-16 code points, including the terminating null character #18

@shearer12345

Description

@shearer12345

Thanks for js-cfb, and for the changes to truncate stream names introduced in 0e33eb6.

The MS-CFB spec says

storage and stream names are limited to 32 UTF-16 code points, including the terminating null character.

Currently, cfb.js truncates stream name to 32 characters, but as the name has to be null terminated, it should be truncated to 31, allowing WriteShift to pad the rest with 0.

So, in cfb.js#894

		if(_nm.length > 32) {
			console.error("Name " + _nm + " will be truncated to " + _nm.slice(0,32));
			_nm = _nm.slice(0, 32);
		}

all the 32s should be 31.

In my testing this doesn't break any of my tools, but some throw warnings:

  • Python compoundfiles - warns missing NULL terminator in name
  • P7Zip - no warnings, displays the character that should be null
  • olebrowse - no warnings, doesn't display the character that should be null
  • olefile - detects no fatal parsing issue "'incorrect DirEntry name length >64 bytes"

I can submit a PR for this if you'd like

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions