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 stack buffer overflow #233

Merged
merged 1 commit into from
Dec 20, 2021
Merged

Fix stack buffer overflow #233

merged 1 commit into from
Dec 20, 2021

Conversation

stoeckmann
Copy link
Contributor

The adjustment of parse_error introduced a possible stack buffer
overflow if lesskey filename is long enough.

How to reproduce:

KEYFILE=$(python -c 'print("/tmp/"+4*(255*"a"+"/")+"lesskey.txt")')
install -d $(dirname KEYFILE)
echo "#version a" > $KEYFILE
less --lesskey-src=$KEYFILE -f /dev/null

The adjustment of parse_error introduced a possible stack buffer
overflow if lesskey filename is long enough.

How to reproduce:

KEYFILE=$(python -c 'print("/tmp/"+4*(255*"a"+"/")+"lesskey.txt")')
install -d $(dirname KEYFILE)
echo "#version a" > $KEYFILE
less --lesskey-src=$KEYFILE -f /dev/null
@stoeckmann
Copy link
Contributor Author

Two notes:

  • Latest stable release does not contain this bug
  • This code uses snprintf directly, but SNPRINTF macros exist in less.h. Maybe it is time to switch code base to more robust snprintf usage

@gwsw gwsw merged commit ae087e2 into gwsw:master Dec 20, 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