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

Fix overflows with malformed lesskey lines #234

Merged
merged 1 commit into from
Dec 25, 2021
Merged

Fix overflows with malformed lesskey lines #234

merged 1 commit into from
Dec 25, 2021

Conversation

stoeckmann
Copy link
Contributor

If lines are malformed it is possible to trigger out of boundary
read accesses during parsing.

Carefully handle the pointer increments to not move behind the
terminating nul byte.

How to reproduce:

python -c 'print(1022*" "+"\")' > lesskey-1.txt
python -c 'print(1022*" "+"^")' > lesskey-2.txt
python -c 'print(1021*" "+"\k")' > lesskey-3.txt

Open these files with lesskey, compiled with -fsanitize=address.

If lines are malformed it is possible to trigger out of boundary
read accesses during parsing.

Carefully handle the pointer increments to not move behind the
terminating nul byte.

How to reproduce:

python -c 'print(1022*" "+"\\")' > lesskey-1.txt
python -c 'print(1022*" "+"^")' > lesskey-2.txt
python -c 'print(1021*" "+"\\k")' > lesskey-3.txt

Open these files with lesskey, compiled with -fsanitize=address.
@stoeckmann
Copy link
Contributor Author

I did not fuzz possible lesskey files so I do not know if this covers all cases. The last adjustment is probably not necessary -- but I added it just in case.

For style reasons it might make sense to modify all *pp = p+1 lines in that function.

@gwsw gwsw merged commit fc0ea4f into gwsw:master Dec 25, 2021
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.

None yet

2 participants