[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libbase/LoadThread.cpp libbase/...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libbase/LoadThread.cpp libbase/... |
Date: |
Sat, 05 May 2007 12:21:13 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/05/05 12:21:13
Modified files:
. : ChangeLog
libbase : LoadThread.cpp tu_file.cpp
Log message:
* libbase/tu_file.cpp (std_get_stream_size_func): use fstat to
get stream size. (other funx for filesystem access): add some
assertions
to prevent seeking past the end of the stream.
* libbase/LoadThread.cpp (read): don't seek past the end of the
stream. Add a few assertions checking that _loadPosition is
never > then _streamSize.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3102&r2=1.3103
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/LoadThread.cpp?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/tu_file.cpp?cvsroot=gnash&r1=1.15&r2=1.16
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3102
retrieving revision 1.3103
diff -u -b -r1.3102 -r1.3103
--- ChangeLog 5 May 2007 08:20:01 -0000 1.3102
+++ ChangeLog 5 May 2007 12:21:12 -0000 1.3103
@@ -1,3 +1,12 @@
+2007-05-04 Sandro Santilli <address@hidden>
+
+ * libbase/tu_file.cpp (std_get_stream_size_func): use fstat to
+ get stream size. (other funx for filesystem access): add some
assertions
+ to prevent seeking past the end of the stream.
+ * libbase/LoadThread.cpp (read): don't seek past the end of the
+ stream. Add a few assertions checking that _loadPosition is
+ never > then _streamSize.
+
2007-05-04 Markus Gothe <address@hidden>
* gui/aqua.cpp: Initial creation.
Index: libbase/LoadThread.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/LoadThread.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- libbase/LoadThread.cpp 2 May 2007 12:11:31 -0000 1.7
+++ libbase/LoadThread.cpp 5 May 2007 12:21:13 -0000 1.8
@@ -16,7 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-// $Id: LoadThread.cpp,v 1.7 2007/05/02 12:11:31 strk Exp $
+// $Id: LoadThread.cpp,v 1.8 2007/05/05 12:21:13 strk Exp $
#include "LoadThread.h"
@@ -172,7 +172,11 @@
memcpy(dst, _cache + (_userPosition - newcachestart), newret);
_userPosition += newret;
_actualPosition = newcachestart + _cachedData;
- if (newcachestart + _cachedData > _loadPosition) _loadPosition =
_actualPosition;
+ if (newcachestart + _cachedData > _loadPosition)
+ {
+ _loadPosition = _actualPosition;
+ assert(_loadPosition <= _streamSize);
+ }
return newret;
}
@@ -278,19 +282,27 @@
void LoadThread::download()
{
if (_loadPosition >= _streamSize) {
+ _loadPosition = _streamSize;
_completed = true;
return;
}
boost::mutex::scoped_lock lock(_mutex);
- _stream->set_position(_loadPosition + _chunkSize);
+ long nextpos = _loadPosition + _chunkSize;
+ if ( nextpos > _streamSize ) nextpos = _streamSize;
+ _stream->set_position(nextpos);
long pos = _stream->get_position();
+ assert(pos != -1); // TODO: unhandled error !
+
+ assert(pos == nextpos);
if (pos != _loadPosition + _chunkSize) {
_completed = true;
}
+
_loadPosition = pos;
+ assert(_loadPosition <= _streamSize);
_actualPosition = pos;
}
Index: libbase/tu_file.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/tu_file.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- libbase/tu_file.cpp 17 Apr 2007 10:38:16 -0000 1.15
+++ libbase/tu_file.cpp 5 May 2007 12:21:13 -0000 1.16
@@ -12,6 +12,10 @@
#include "membuf.h"
#include "log.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
//
// tu_file functions using FILE
//
@@ -19,6 +23,16 @@
using namespace gnash;
namespace gnash {
+
+static int std_read_func(void* dst, int bytes, void* appdata);
+static int std_write_func(const void* src, int bytes, void* appdata);
+static int std_seek_func(int pos, void *appdata);
+static int std_seek_to_end_func(void *appdata);
+static int std_tell_func(void *appdata);
+static bool std_get_eof_func(void *appdata);
+static int std_get_err_func(void *appdata);
+static long std_get_stream_size_func(void *appdata);
+
static int
std_read_func(void* dst, int bytes, void* appdata)
// Return the number of bytes actually read. EOF or an error would
@@ -45,6 +59,10 @@
// Return 0 on success, or TU_FILE_SEEK_ERROR on failure.
{
assert(appdata);
+
+ // TODO: I guess we don't want to allow seeking after stream size, do we ?
+ assert(pos <= std_get_stream_size_func(appdata));
+
clearerr((FILE*) appdata); // make sure EOF flag is cleared.
int result = fseek((FILE*)appdata, pos, SEEK_SET);
if (result == EOF) {
@@ -72,7 +90,14 @@
// Return the file position, or -1 on failure.
{
assert(appdata);
- return ftell((FILE*)appdata);
+ FILE* f = static_cast<FILE*>(appdata);
+
+ //if ( feof(f) )
+ assert ( ! feof(f) );
+
+ int ret = ftell(f);
+ assert(ret <= std_get_stream_size_func(appdata));
+ return ret;
}
static bool
@@ -100,13 +125,16 @@
// Return -1 on failure, or the size
{
assert(appdata);
- int org_pos = ftell((FILE*)appdata);
- fseek((FILE*)appdata, 0, SEEK_END);
- int ret = ftell((FILE*)appdata);
+ FILE* f = static_cast<FILE*>(appdata);
- fseek((FILE*)appdata, org_pos, SEEK_SET);
- return ret;
+ struct stat statbuf;
+ if ( -1 == fstat(fileno(f), &statbuf) )
+ {
+ log_error("Could not fstat file");
+ return 0;
+ }
+ return statbuf.st_size;
}