Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
be sure that we don't try to read bytes after the end of the file
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 25 Sep 2015 14:05:48 +0000 (16:05 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Fri, 25 Sep 2015 17:21:35 +0000 (19:21 +0200)
src/surf/storage_n11.cpp

index 8fc1ede..42fef37 100644 (file)
@@ -433,7 +433,11 @@ StorageAction *StorageN11::close(surf_file_t fd)
 StorageAction *StorageN11::read(surf_file_t fd, sg_size_t size)
 {
   if(fd->current_position + size > fd->size){
 StorageAction *StorageN11::read(surf_file_t fd, sg_size_t size)
 {
   if(fd->current_position + size > fd->size){
-    size = fd->size - fd->current_position;
+    if (fd->current_position > fd->size){
+      size = 0;
+    } else {
+      size = fd->size - fd->current_position;
+    }
     fd->current_position = fd->size;
   }
   else
     fd->current_position = fd->size;
   }
   else