filesrc: catch failure to seek back to zero after seek test
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 7 Apr 2014 14:18:32 +0000 (15:18 +0100)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Mon, 7 Apr 2014 14:24:26 +0000 (15:24 +0100)
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

index c7913fa..8f6b904 100644 (file)
@@ -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: