In av_seek_frame_generic there are many calls to url_fseek that look like this: if ((ret = url_fseek(s->pb, ie->pos, SEEK_SET)) < 0) return ret; Unfortunately, ret is declared as int, while url_fseek returns int64_t, so the return value will be truncated before being compared with zero. Since url_fseek returns the current position on success, certain values (2GB-4GB for instance) will be interpreted as negative values despite being positive 64-bit values. This patch declares ret as an int64_t so that truncation does not occur until the value is actually returned. --- libavformat/utils.c (revision 20690) +++ libavformat/utils.c (working copy) @@ -1513,7 +1513,8 @@ static int av_seek_frame_byte(AVFormatCo static int av_seek_frame_generic(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { - int index, ret; + int index; + int64_t ret; AVStream *st; AVIndexEntry *ie;
On Tue, Dec 01, 2009 at 02:21:43PM -0800, Sean Soria wrote:
In av_seek_frame_generic there are many calls to url_fseek that look like this: if ((ret = url_fseek(s->pb, ie->pos, SEEK_SET)) < 0) return ret;
Unfortunately, ret is declared as int, while url_fseek returns int64_t, so the return value will be truncated before being compared with zero. Since url_fseek returns the current position on success, certain values (2GB-4GB for instance) will be interpreted as negative values despite being positive 64-bit values. This patch declares ret as an int64_t so that truncation does not occur until the value is actually returned.
--- libavformat/utils.c (revision 20690) +++ libavformat/utils.c (working copy) @@ -1513,7 +1513,8 @@ static int av_seek_frame_byte(AVFormatCo static int av_seek_frame_generic(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { - int index, ret; + int index; + int64_t ret; AVStream *st; AVIndexEntry *ie;
ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The bravest are surely those who have the clearest vision of what is before them, glory and danger alike, and yet notwithstanding go out to meet it. -- Thucydides
On 12/01/2009 02:53 PM, Michael Niedermayer wrote:
On Tue, Dec 01, 2009 at 02:21:43PM -0800, Sean Soria wrote:
In av_seek_frame_generic there are many calls to url_fseek that look like this: if ((ret = url_fseek(s->pb, ie->pos, SEEK_SET))< 0) return ret;
Unfortunately, ret is declared as int, while url_fseek returns int64_t, so the return value will be truncated before being compared with zero. Since url_fseek returns the current position on success, certain values (2GB-4GB for instance) will be interpreted as negative values despite being positive 64-bit values. This patch declares ret as an int64_t so that truncation does not occur until the value is actually returned.
--- libavformat/utils.c (revision 20690) +++ libavformat/utils.c (working copy) @@ -1513,7 +1513,8 @@ static int av_seek_frame_byte(AVFormatCo static int av_seek_frame_generic(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { - int index, ret; + int index; + int64_t ret; AVStream *st; AVIndexEntry *ie;
ok
Applied. -- Baptiste COUDURIER Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA FFmpeg maintainer http://www.ffmpeg.org
participants (3)
-
baptiste.coudurier@gmail.com -
michaelni@gmx.at -
sean.soria@gmail.com