* StreamReader::ReadAt(): Passed incorrect size to _ReadDirectItem(), which

could cause a memory read access beyond the block, resulting in a crash, if
  nothing was mapped there.
* Automatic white space cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35915 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-03-19 18:11:32 +00:00
parent f0330c4aff
commit 02cb896640

View File

@ -1,17 +1,17 @@
// Iterators.h // Iterators.h
// //
// Copyright (c) 2003, Ingo Weinhold (bonefish@cs.tu-berlin.de) // Copyright (c) 2003-2010, Ingo Weinhold (bonefish@cs.tu-berlin.de)
// //
// This program is free software; you can redistribute it and/or modify // This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -19,7 +19,9 @@
// You can alternatively use *this file* under the terms of the the MIT // You can alternatively use *this file* under the terms of the the MIT
// license included in this package. // license included in this package.
#include "Iterators.h" #include "Iterators.h"
#include "Block.h" #include "Block.h"
#include "BlockCache.h" #include "BlockCache.h"
#include "Key.h" #include "Key.h"
@ -27,6 +29,7 @@
#include "StatItem.h" #include "StatItem.h"
#include "Tree.h" #include "Tree.h"
// min and max // min and max
// We don't want to include <algobase.h> otherwise we also get <iostream.h> // We don't want to include <algobase.h> otherwise we also get <iostream.h>
// and other undesired things. // and other undesired things.
@ -246,7 +249,7 @@ TreeIterator::GetLevel() const
- \c DOWN: Down one level (in leaf direction). Goes to the child node of - \c DOWN: Down one level (in leaf direction). Goes to the child node of
the current node the iterator currently points at. Points afterwards to the current node the iterator currently points at. Points afterwards to
the 0th child node of the new current node (unless it is a leaf node). the 0th child node of the new current node (unless it is a leaf node).
\c FORWARD and \c BACKWARDS do not change the current node! \c FORWARD and \c BACKWARDS do not change the current node!
\param direction \c FORWARD, \c BACKWARDS, \c UP or \c DOWN \param direction \c FORWARD, \c BACKWARDS, \c UP or \c DOWN
@ -799,7 +802,7 @@ ItemIterator::_SearchRightMost(LeafNode *node, const VKey *k,
This class basically wraps the ItemIterator class and provides a This class basically wraps the ItemIterator class and provides a
more convenient interface for iteration through items of one given more convenient interface for iteration through items of one given
object (directory, link or file). It finds only items of the object object (directory, link or file). It finds only items of the object
identified by the dir and object ID specified on initialization. identified by the dir and object ID specified on initialization.
*/ */
// constructor // constructor
@ -1340,7 +1343,7 @@ StreamReader::ReadAt(off_t position, void *buffer, size_t bufferSize,
error = _ReadIndirectItem(inItemOffset, buffer, toRead); error = _ReadIndirectItem(inItemOffset, buffer, toRead);
break; break;
case TYPE_DIRECT: case TYPE_DIRECT:
error = _ReadDirectItem(inItemOffset, buffer, bufferSize); error = _ReadDirectItem(inItemOffset, buffer, toRead);
break; break;
case TYPE_STAT_DATA: case TYPE_STAT_DATA:
case TYPE_DIRENTRY: case TYPE_DIRENTRY: