This file is indexed.

/usr/include/wv2/olestream.h is in libwv2-dev 0.4.2.dfsg.1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
/* This file is part of the wvWare 2 project
   Copyright (C) 2001-2003 Werner Trobin <trobin@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/

#ifndef OLESTREAM_H
#define OLESTREAM_H

#include "olestorage.h"
#include "global.h"  // U8,... typedefs
#include <stack>

#include <glib/giochannel.h> // GSeekType

namespace wvWare {

class OLEStream
{
public:
    /**
     * Create an OLE stream
     */
    OLEStream( OLEStorage* storage );
    virtual ~OLEStream();

    /**
     * Is this still a valid stream?
     */
    virtual bool isValid() const = 0;

    /**
     * works like plain fseek
     */
    virtual bool seek( int offset, GSeekType whence = G_SEEK_SET ) = 0;
    /**
     * works like plain ftell
     */
    virtual int tell() const = 0;
    /**
     * The size of the stream
     */
    virtual size_t size() const = 0;

    /**
     * Push the current offset on the stack
     */
    void push();
    /**
     * Pop the topmost position (false if the stack was empty)
     */
    bool pop();

private:
    /**
     * we don't want to allow copying and assigning streams
     */
    OLEStream( const OLEStream& rhs );
    /**
     * we don't want to allow copying and assigning streams
     */
    OLEStream& operator=( const OLEStream& rhs );

    std::stack<int> m_positions;
    /**
     *  for bookkeeping :}
     */
    OLEStorage *m_storage;
};


class OLEStreamReader : public OLEStream
{
public:
    OLEStreamReader( GsfInput* stream, OLEStorage* storage );
    virtual ~OLEStreamReader();

    /**
     * Is this still a valid stream?
     */
    virtual bool isValid() const;

    /**
     * works like plain fseek
     */
    virtual bool seek( int offset, GSeekType whence = G_SEEK_SET );
    /**
     * works like plain ftell
     */
    virtual int tell() const;
    /**
     * The size of the stream
     */
    virtual size_t size() const;
    /**
     * decompress LZ compress bits in a stream
     * and return a new OLEStreamReader with the data
     */
    virtual OLEStreamReader* inflate( int offset ) const;

    /**
     * Reading from the current position
     * Note: Modifies the current position!
     * All the read methods are endian-aware and convert
     * the contents from the file if necessary
     */
    U8 readU8();
    /**
     * @see readU8()
     */
    S8 readS8();
    /**
     * @see readU8()
     */
    U16 readU16();
    /**
     * @see readU8()
     */
    S16 readS16();
    /**
     * @see readU8()
     */
    U32 readU32();
    /**
     * @see readU8()
     */
    S32 readS32();

    /**
     * Reads a bunch of bytes w/o endian conversion to the
     * given buffer, at most length bytes.
     * Returns true on success
     */
    bool read( U8 *buffer, size_t length );

    /**
     * For debugging
     */
    void dumpStream( const std::string& fileName );

private:
    // we don't want to allow copying and assigning streams
    OLEStreamReader( const OLEStreamReader& rhs );
    OLEStreamReader& operator=( const OLEStreamReader& rhs );

    GsfInput* m_stream;
};


/**
 * OLEImageReader provides bounds-checked access to a stream.
 * Objects of this class are used to safely provide image data to
 * the consumer.
 * It doesn't actually own an OLE stream, it just wraps the access
 * to the real data stream. In that wrapper code it also performs
 * the bounds checking.
 * Note that this stream class, unlike the other two classes, doesn't
 * fix the endianness of the data!
 */
class OLEImageReader
{
public:
    /**
     * Constructs a limited reader which is only allowed to read the passed
     * OLEStreamReader from start up to, but not including, limit.
     */
    OLEImageReader( OLEStreamReader& reader, unsigned int start, unsigned int limit );
    OLEImageReader( const OLEImageReader& rhs );

    ~OLEImageReader();

    /**
     * Is this still a valid stream?
     */
    bool isValid() const;

    /**
     * Works like plain fseek, with the limitation of the defined region.
     */
    bool seek( int offset, GSeekType whence = G_SEEK_SET );
    /**
     * Works like plain ftell
     */
    int tell() const;
    /**
     * The size of the region that's available to the user of this class.
     */
    size_t size() const;

    /**
     * Reads a bunch of bytes w/o endian conversion to the
     * given buffer, at most length bytes. The position in the stream
     * is changed, too.
     * Returns the number of bytes read.
     */
    size_t read( U8 *buffer, size_t length );

private:
    // It doesn't make sense to assign them (copying is fine, though)
    OLEImageReader& operator=( const OLEImageReader& rhs );

    // Updates the position, if it's valid. Returns false if the passed
    // position is out of the range.
    bool updatePosition( unsigned int position );

    OLEStreamReader& m_reader;
    const unsigned int m_start;
    const unsigned int m_limit;

    // Keeps track of the "virtual" position. We aren't allowed
    // to change the state of the real stream, so we have to push/pop
    // the real position every time one of the OLEImageReader methods
    // is called. We want to fake a consistent internal state, though,
    // so we have to remember the "virtual" position here.
    // Initialized with the m_start value.
    unsigned int m_position;
};


class OLEStreamWriter : public OLEStream
{
public:
    OLEStreamWriter( GsfOutput* stream, OLEStorage* storage );
    virtual ~OLEStreamWriter();

    /**
     * Is this still a valid stream?
     */
    virtual bool isValid() const;

    /**
     * works like plain fseek
     */
    virtual bool seek( int offset, GSeekType whence = G_SEEK_SET );
    /**
     * works like plain ftell
     */
    virtual int tell() const;
    /**
     * The size of the stream
     */
    virtual size_t size() const;

    /**
     * Writing to the current position
     * Note: Modifies the current position!
     * These write methods are endian-aware
     * and convert the contents to be LE in the file
     */
    void write( U8 data );
    /**
     * @see write(U8 data)
     */
    void write( S8 data );
    /**
     * @see write(U8 data)
     */
    void write( U16 data );
    /**
     * @see write(U8 data)
     */
    void write( S16 data );
    /**
     * @see write(U8 data)
     */
    void write( U32 data );
    /**
     * @see write(U8 data)
     */
    void write( S32 data );

    /**
     * Attention: This write method just writes out the
     * contents of the memory directly (w/o converting
     * to little-endian first!)
     */
    void write( U8* data, size_t length );

    /**
     * give access to GSF stream
     * probably should find another way of doing this
     */
    GsfOutput* getGsfStream();

private:
    // we don't want to allow copying and assigning streams
    OLEStreamWriter( const OLEStreamWriter& rhs );
    OLEStreamWriter& operator=( const OLEStreamWriter& rhs );

    GsfOutput* m_stream;
};

} // namespace wvWare

#endif // OLESTREAM_H