diff --git a/ffserver.c b/ffserver.c
index bab40a327506a232683425196ae77fe9a1bf578c..c8f9cecf4446e519a04de1f14e46d2c4c13633ce 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -333,7 +333,8 @@ static int64_t ffm_read_write_index(int fd)
 {
     uint8_t buf[8];
 
-    lseek(fd, 8, SEEK_SET);
+    if (lseek(fd, 8, SEEK_SET) < 0)
+        return AVERROR(EIO);
     if (read(fd, buf, 8) != 8)
         return AVERROR(EIO);
     return AV_RB64(buf);