45b1087e74
In a multibyte locale such as en_GB.UTF-8, the pg command cannot handle files containing a form feed character (ASCII 0x0c) at the start of a line. The program enters an infinite loop. I've traced the problem to the function endline_for_mb in file pg.c. The code assumes that the libc function wcwidth will return a nonnegative value, which is not true for a form feed character. wcwidth returns -1 and the unsigned variable "pos" goes into underflow. I'll attach a patch which tests whether the character is printable before calling wcwidth. If not, it uses instead the width of the constant L'?' which is later used to replace nonprintable characters. I trust that we can assume printability of this constant :-) Steps to Reproduce: 1. Select a multibyte locale (tested with en_GB.UTF-8) 2. Create a file with a form feed character (0x0c) at the start of a line. 3. Try to display this file using the pg command. Reported-by: Mark Calderbank <m.calderbank@iname.com> Reported-by: Mike Frysinger <vapier@gentoo.org> Addresses: https://bugs.gentoo.org/297717 Signed-off-by: Karel Zak <kzak@redhat.com> |
||
---|---|---|
.. | ||
.gitignore | ||
LICENSE.pg | ||
Makefile.am | ||
README.clear | ||
README.col | ||
README.pg | ||
col.1 | ||
col.c | ||
colcrt.1 | ||
colcrt.c | ||
colrm.1 | ||
colrm.c | ||
column.1 | ||
column.c | ||
conv.c | ||
display.c | ||
hexdump.1 | ||
hexdump.c | ||
hexdump.h | ||
hexsyntax.c | ||
line.1 | ||
line.c | ||
more.1 | ||
more.c | ||
od.1 | ||
odsyntax.c | ||
parse.c | ||
pg.1 | ||
pg.c | ||
rev.1 | ||
rev.c | ||
tailf.1 | ||
tailf.c | ||
ul.1 | ||
ul.c |
README.pg
README for the "pg" utility for Linux. The "pg" utility is the historic System V equivalent to BSD's "more". This is a free clone of it, and it is intended to conform to the SVID 4 as well as the SUSv2 specification of this command. Contrasting to the System V implementation, this one filters backspace formatting sequences while searching, so you can comfortably search in nroff output like manual pages. This code uses routines as defined by SUSv2, so a glibc version of 2.1 or higher is required on Linux. A curses implementation (like ncurses) must be present as well. If large files > 2GB are supported by the kernel and the C library, pg is able to handle them. Please send comments, bug-reports and especially bug-fixes to <g-r@bigfoot.de> . Gunnar Ritter Freiburg i. Br. Germany