From 1a08e22845ea55097d3f41bb965e7870fa9bf6b1 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Mon, 7 Apr 2014 15:18:32 +0100 Subject: [PATCH] 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 --- plugins/elements/gstfilesrc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c index c7913fab3e..8f6b904425 100644 --- a/plugins/elements/gstfilesrc.c +++ b/plugins/elements/gstfilesrc.c @@ -482,7 +482,12 @@ gst_file_src_start (GstBaseSrc * basesrc) } else { 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 @@ -533,6 +538,13 @@ was_socket: (_("File \"%s\" is a socket."), src->filename), (NULL)); 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: close (src->fd); error_exit: