mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 10:48:02 +00:00
MFV: less: Do not trust st_size if it equals zero
This is a smaller version of upstream 1fafd968b48e5cea6c85f126d77071a8de707a55 to address the issue that less not being able to operate on files residing in pseudo-filesystems that advertize a zero size value. PR: bin/276133 MFC after: 3 days
This commit is contained in:
commit
cae336280b
|
@ -700,7 +700,6 @@ public void ch_flush(void)
|
||||||
ch_block = 0; /* ch_fpos / LBUFSIZE; */
|
ch_block = 0; /* ch_fpos / LBUFSIZE; */
|
||||||
ch_offset = 0; /* ch_fpos % LBUFSIZE; */
|
ch_offset = 0; /* ch_fpos % LBUFSIZE; */
|
||||||
|
|
||||||
#if HAVE_PROCFS
|
|
||||||
/*
|
/*
|
||||||
* This is a kludge to workaround a Linux kernel bug: files in
|
* This is a kludge to workaround a Linux kernel bug: files in
|
||||||
* /proc have a size of 0 according to fstat() but have readable
|
* /proc have a size of 0 according to fstat() but have readable
|
||||||
|
@ -709,17 +708,9 @@ public void ch_flush(void)
|
||||||
*/
|
*/
|
||||||
if (ch_fsize == 0)
|
if (ch_fsize == 0)
|
||||||
{
|
{
|
||||||
struct statfs st;
|
ch_fsize = NULL_POSITION;
|
||||||
if (fstatfs(ch_file, &st) == 0)
|
ch_flags &= ~CH_CANSEEK;
|
||||||
{
|
|
||||||
if (st.f_type == PROC_SUPER_MAGIC)
|
|
||||||
{
|
|
||||||
ch_fsize = NULL_POSITION;
|
|
||||||
ch_flags &= ~CH_CANSEEK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (lseek(ch_file, (off_t)0, SEEK_SET) == BAD_LSEEK)
|
if (lseek(ch_file, (off_t)0, SEEK_SET) == BAD_LSEEK)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue