filesrc: catch failure to seek back to zero after seek test

This should never happen theoretically, but since a transient
failure would get us to silently read wrong data, it's worth
erroring out. And it silence this:

Coverity 206034
This commit is contained in:
Vincent Penquerc'h 2014-04-07 15:18:32 +01:00
parent 191ca95fd9
commit 1a08e22845

View file

@ -482,7 +482,12 @@ gst_file_src_start (GstBaseSrc * basesrc)
} else { } else {
src->seekable = TRUE; src->seekable = TRUE;
} }
lseek (src->fd, 0, SEEK_SET); res = lseek (src->fd, 0, SEEK_SET);
if (res < 0) {
/* We really don't like not being able to go back to 0 */
src->seekable = FALSE;
goto lseek_wonky;
}
} }
/* We can only really do seeking on regular files - for other file types, we /* We can only really do seeking on regular files - for other file types, we
@ -533,6 +538,13 @@ was_socket:
(_("File \"%s\" is a socket."), src->filename), (NULL)); (_("File \"%s\" is a socket."), src->filename), (NULL));
goto error_close; goto error_close;
} }
lseek_wonky:
{
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
(_("File \"%s\" could not seek back to zero after seek test."),
src->filename), (NULL));
goto error_close;
}
error_close: error_close:
close (src->fd); close (src->fd);
error_exit: error_exit: