Skip to content

Fix stack buffer overflow#233

Merged
gwsw merged 1 commit into
gwsw:masterfrom
stoeckmann:stack
Dec 20, 2021
Merged

Fix stack buffer overflow#233
gwsw merged 1 commit into
gwsw:masterfrom
stoeckmann:stack

Conversation

@stoeckmann

Copy link
Copy Markdown
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
Copy Markdown
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.

2 participants