Avoid a potential overflow when 'skip' is larger than a pointer.

Thanks to: Joerg Sonnenberger
This commit is contained in:
Tim Kientzle 2007-04-02 00:25:11 +00:00
parent 25d4e0e5ab
commit 96e31e81ff
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=168233

View File

@ -134,7 +134,7 @@ memory_read_skip(struct archive *a, void *client_data, off_t skip)
struct read_memory_data *mine = (struct read_memory_data *)client_data;
(void)a; /* UNUSED */
if (mine->buffer + skip > mine->end)
if (skip > mine->end - mine->buffer)
skip = mine->end - mine->buffer;
/* Round down to block size. */
skip /= mine->read_size;