MFC: hexdump: Do not trust st_size if it equals zero.
PR: bin/276106
(cherry picked from commit e23954bd42)
This commit is contained in:
parent
0bb4c188d3
commit
538bf98c7c
1 changed files with 3 additions and 2 deletions
|
|
@ -397,13 +397,14 @@ doskip(const char *fname, int statok)
|
|||
if (statok) {
|
||||
if (fstat(fileno(stdin), &sb))
|
||||
err(1, "%s", fname);
|
||||
if (S_ISREG(sb.st_mode) && skip > sb.st_size) {
|
||||
if (S_ISREG(sb.st_mode) && skip > sb.st_size && sb.st_size > 0) {
|
||||
address += sb.st_size;
|
||||
skip -= sb.st_size;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!statok || S_ISFIFO(sb.st_mode) || S_ISSOCK(sb.st_mode)) {
|
||||
if (!statok || S_ISFIFO(sb.st_mode) || S_ISSOCK(sb.st_mode) || \
|
||||
(S_ISREG(sb.st_mode) && sb.st_size == 0)) {
|
||||
noseek();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue