usb-mtp: handle lseek failure

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2014-05-20 13:02:26 +02:00
parent 36084d7e31
commit 68206d7342

View File

@ -702,7 +702,10 @@ static MTPData *usb_mtp_get_partial_object(MTPState *s, MTPControl *c,
if (offset > o->stat.st_size) {
offset = o->stat.st_size;
}
lseek(d->fd, offset, SEEK_SET);
if (lseek(d->fd, offset, SEEK_SET) < 0) {
usb_mtp_data_free(d);
return NULL;
}
d->length = c->argv[2];
if (d->length > o->stat.st_size - offset) {