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

Preset names are not escaped / treated as literal #28

Closed
Tkael opened this issue Jul 18, 2021 · 6 comments
Closed

Preset names are not escaped / treated as literal #28

Tkael opened this issue Jul 18, 2021 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Tkael
Copy link

Tkael commented Jul 18, 2021

The DetectBindsFile method can reject preset names containing Regex special characters and can return a "No bindings file found" error instead. For example, with my bindings file "T16000M HOTAS (T'kael).4.0.binds" the parenthesis are treated as regex characters rather than as part of the literal prefix name which causes a mismatch. The prefix name needs to be treated literally.

@alterNERDtive
Copy link
Owner

We’ve had SQL injection, but what about regex injection⁈ :)

@alterNERDtive alterNERDtive self-assigned this Jul 18, 2021
@alterNERDtive alterNERDtive added the bug Something isn't working label Jul 18, 2021
@Tkael
Copy link
Author

Tkael commented Jul 18, 2021

I'm looking at changing lines 301-303 of bindED.cs to

            FileInfo[] bindFiles = dirInfo.GetFiles()
                .Where(i => Regex.Match(i.Name, $@"^{Regex.Escape(preset ?? string.Empty)}\.[34]\.0\.binds$").Success)
                .OrderByDescending(p => p.Name).ToArray();

@Tkael
Copy link
Author

Tkael commented Jul 18, 2021

The change seems to be working.

10:53:57.115 INFO | bindED: Elite binds 'T16000M HOTAS (T'kael)' for layout 'en-us' loaded successfully.

@alterNERDtive
Copy link
Owner

I should have just let you do a pull request instead of doing the exact same thing in parallel =p

Anyway, the nullable preset parameter didn’t really make sense, so instead of doing a Regex.Escape(preset ?? string.Empty) I changed that instead.

@alterNERDtive
Copy link
Owner

(fixed next release which I’m probably going to do soon™ in light of this bug)

@Tkael
Copy link
Author

Tkael commented Jul 18, 2021

Fixed locally in the meantime. Thanks. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants