Skip to content

Commit

Permalink
Fix bug when first byte from a LESSOPEN script is non-ASCII.
Browse files Browse the repository at this point in the history
open_altfile reads one byte to see if the LESSSOPEN script will
produce any data, then pushes it back on the input queue via
ch_ungetchar. But the variable is declared as "char", so if the
first byte has the high bit set, and the compiler uses signed chars,
this will sign-extend and pass a negative value to ch_ungetchar.
ch_ungetchar takes a negative value as a signal to discard any
queued char.
  • Loading branch information
gwsw committed Sep 11, 2024
1 parent c06a2a5 commit 03f9f1a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ public char * open_altfile(constant char *filename, int *pf, void **pfd)
#if HAVE_FILENO
if (returnfd)
{
char c;
unsigned char c;
int f;

/*
Expand Down

0 comments on commit 03f9f1a

Please sign in to comment.