Skip to content

Fix potential crash on windows if raw.FileNameLength exceeds syscall.MAX_PATH#361

Merged
mattn merged 5 commits intofsnotify:mainfrom
PreVeil:issue-318
Jan 26, 2022
Merged

Fix potential crash on windows if raw.FileNameLength exceeds syscall.MAX_PATH#361
mattn merged 5 commits intofsnotify:mainfrom
PreVeil:issue-318

Conversation

@hu13
Copy link
Copy Markdown
Contributor

@hu13 hu13 commented Mar 3, 2021

What does this pull request do?

Fix #318.

Where should the reviewer start?

How should this be manually tested?

The crash only happens when we enable recursive watch on windows here: https://github.com/fsnotify/fsnotify/blob/master/windows.go#L350 by changing the argument flag from false to true.

Then if we create a really long filepath (see code snippet in #318), and begin watching on the first parent directory of that path and let the recursive watch propagates, fsnotify will crash.

panic: runtime error: slice bounds out of range

goroutine 765 [running, locked to thread]:

filesync_daemon/fsnotify.(*Watcher).readEvents(0xc000c78f40)

        /home/builder/go/src/filesync_daemon/fsnotify/windows.go:456 +0xfb1

created by filesync_daemon/fsnotify.NewWatcher

        /home/builder/go/src/filesync_daemon/fsnotify/windows.go:46 +0x21c

@mattn mattn merged commit 712fe1d into fsnotify:main Jan 26, 2022
@mattn
Copy link
Copy Markdown
Member

mattn commented Jan 26, 2022

Thank you

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fsnotify can crash on windows if raw.FileNameLength exceeds syscall.MAX_PATH

2 participants