mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zdump: catch attempts to seek past end of file in zg_seek()
Make zg_seek() more robust. Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> Reviewed-by: Philipp Rudo <prudo@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
0a7df9e030
commit
11e78cada5
@@ -280,6 +280,9 @@ off_t zg_seek(struct zg_fh *zg_fh, off_t off, enum zg_check check)
|
||||
{
|
||||
off_t rc;
|
||||
|
||||
if (off >= zg_fh->sb.st_size)
|
||||
ERR_EXIT("Trying to seek past file end \"%s\"", zg_fh->path);
|
||||
|
||||
rc = lseek(zg_fh->fh, off, SEEK_SET);
|
||||
if (rc == -1 && check != ZG_CHECK_NONE)
|
||||
ERR_EXIT_ERRNO("Could not seek \"%s\"", zg_fh->path);
|
||||
|
||||
Reference in New Issue
Block a user