[vlc-devel] [PATCH] Bug fix: Do not close an http stream when seeking past the EOF

Rémi Denis-Courmont rdenis at simphalempin.com
Tue Jun 17 20:06:56 CEST 2008

Le mardi 17 juin 2008 20:55:07 Bill C. Riemers, vous avez écrit :
> > Yeah. That can only ever fail if the reader is stupid enough to try to
> > seek while CAN_SEEK is false, as far as I can tell though.
> Hmm.  The failure case in file.c is the module tries to seek past the
> EOF.  In that case, since the stream is open read only the lseek returns
> EINVAL.  The location of the file pointer is left at it's previous
> position, and p_access->info.i_pos says it is past the EOF location.
> I'm surprised this doesn't cause really bad things to happen...

As far as I know lseek can only EINVAL beyond end of file for special files. 
But VLC only sets b_seekable for regular files. This leaves two corner case:
- attempt to set a negative offset
- attempt to use Seek() even though CAN_SEEK is false.

> BTW.  It just occurred to me.  Shouldn't file.c be using lseek64, not
> lseek?

We're setting _FILE_OFFSET_BITS to 64 on Linux. This avoids having to use 
Linuxisms *64() all over the place.

Rémi Denis-Courmont

More information about the vlc-devel mailing list