vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / media / plugins / matroska / libebml / EbmlDate.cpp
blob32d49abac037061aa97052a7817e42f4d88b6ef9
1 /****************************************************************************
2 ** libebml : parse EBML files, see http://embl.sourceforge.net/
3 **
4 ** <file/class description>
5 **
6 ** Copyright (C) 2002-2005 Steve Lhomme. All rights reserved.
7 **
8 ** This library is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU Lesser General Public
10 ** License as published by the Free Software Foundation; either
11 ** version 2.1 of the License, or (at your option) any later version.
12 **
13 ** This library is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ** Lesser General Public License for more details.
17 **
18 ** You should have received a copy of the GNU Lesser General Public
19 ** License along with this library; if not, write to the Free Software
20 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 ** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
24 ** Contact license@matroska.org if any conditions of this licensing are
25 ** not clear to you.
27 **********************************************************************/
29 /*!
30 \file
31 \version \$Id: EbmlDate.cpp 1079 2005-03-03 13:18:14Z robux4 $
32 \author Steve Lhomme <robux4 @ users.sf.net>
34 #include <cassert>
36 #include "ebml/EbmlDate.h"
38 START_LIBEBML_NAMESPACE
40 const uint64 EbmlDate::UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
42 EbmlDate::EbmlDate(const EbmlDate & ElementToClone)
43 :EbmlElement(ElementToClone)
45 myDate = ElementToClone.myDate;
48 uint64 EbmlDate::ReadData(IOCallback & input, ScopeMode ReadFully)
50 if (ReadFully != SCOPE_NO_DATA)
52 if (Size != 0) {
53 assert(Size == 8);
54 binary Buffer[8];
55 input.readFully(Buffer, Size);
57 big_int64 b64;
58 b64.Eval(Buffer);
60 myDate = b64;
61 bValueIsSet = true;
65 return Size;
68 uint32 EbmlDate::RenderData(IOCallback & output, bool bForceRender, bool bKeepIntact)
70 if (Size != 0) {
71 assert(Size == 8);
72 big_int64 b64(myDate);
74 output.writeFully(&b64.endian(),Size);
77 return Size;
80 END_LIBEBML_NAMESPACE