gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_start-


From: Bastiaan Jacques
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. release_0_8_9_start-232-g84dd2a6
Date: Thu, 10 Mar 2011 14:14:20 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  84dd2a6e8461d8b1ef6d5ed9b78a547da4efa0d1 (commit)
      from  189cb72c06767e8d7ffce6daf39a88cd522b8ed0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=84dd2a6e8461d8b1ef6d5ed9b78a547da4efa0d1


commit 84dd2a6e8461d8b1ef6d5ed9b78a547da4efa0d1
Author: Bastiaan Jacques <address@hidden>
Date:   Thu Mar 10 15:13:13 2011 +0100

    Avoid integer overflow while checking file sizes for seeks. Add a test for 
32-bit machines.

diff --git a/libbase/tu_file.cpp b/libbase/tu_file.cpp
index 17159d0..b9aa13b 100644
--- a/libbase/tu_file.cpp
+++ b/libbase/tu_file.cpp
@@ -171,14 +171,14 @@ bool
 tu_file::seek(std::streampos pos)
 {
     // TODO: optimize this by caching total stream size ?
-    if (static_cast<size_t>(pos) > size()) return false;
+    if (pos > static_cast<std::streampos>(size())) return false;
 
     std::clearerr(_data); // make sure EOF flag is cleared.
     const int result = std::fseek(_data, pos, SEEK_SET);
     if (result == EOF) {
         return false;
     }
-
+    assert (pos < std::numeric_limits<long>::max());
     assert (std::ftell(_data) == pos);
 
     return true;
diff --git a/testsuite/libbase.all/NoSeekFileTest.cpp 
b/testsuite/libbase.all/NoSeekFileTest.cpp
index bca1476..7762d69 100644
--- a/testsuite/libbase.all/NoSeekFileTest.cpp
+++ b/testsuite/libbase.all/NoSeekFileTest.cpp
@@ -41,6 +41,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <sstream>
+#include <limits>
 
 using namespace std;
 
@@ -153,6 +154,20 @@ main(int /*argc*/, char** /*argv*/)
        lseek(raw, 0, SEEK_SET);
        compare_reads(orig.get(), raw, "cache", "raw");
 
+
+    if (sizeof(size_t) != sizeof(std::streamoff)) {
+        std::streampos pos = std::numeric_limits<size_t>::max();
+        pos += orig->size() / 2;
+        // Check that seek() handles integer overflow situations gracefully.
+        if (orig->seek(pos)) {
+            runtest.fail("Successfully sought to an invalid position.");
+        } else {
+            runtest.pass("Gracefully handled invalid seek.");
+        }
+    }
+
+
+
        return 0;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 libbase/tu_file.cpp                      |    4 ++--
 testsuite/libbase.all/NoSeekFileTest.cpp |   15 +++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]