Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 354193
Collapse All | Expand All

(-)a/lib/oleinputstream.cpp (-12 / +19 lines)
Lines 173-205 OleInputStream::Private::Private(OleInputStream* s, InputStream* input) Link Here
173
        stream->m_error = "Invalid OLE file.";
173
        stream->m_error = "Invalid OLE file.";
174
        return;
174
        return;
175
    }
175
    }
176
    int32_t max = 0;
177
    batIndex.reserve(nBat);
176
    batIndex.reserve(nBat);
178
    data += 76;
177
    data += 76;
179
    for (int i = 0; i < ::min(109, nBat); ++i) {
178
    for (int i = 0; i < ::min(109, nBat); ++i) {
180
        int32_t p = readLittleEndianInt32(data+4*i);
179
        int32_t p = readLittleEndianInt32(data+4*i);
181
        batIndex.push_back(p);
180
        batIndex.push_back(p);
182
        if (p > max) max = p;
183
    }
181
    }
184
    if (ptOffset > max) max = ptOffset;
185
    if (128*(nBat-1) > max) max = 128*(nBat-1);
186
182
187
    int32_t toread = (max+2)*512;
183
    // this looks wrong? what's with input->size() < 0
188
    if (input->size() >= 0 && input->size() < toread) {
184
    // toread = 10000000 later on, why not bail out here?
185
/*    if (input->size() >= 0 && input->size() < toread) {
189
        stream->m_status = Error;
186
        stream->m_status = Error;
190
        stream->m_error = "File is incomplete.";
187
        stream->m_error = "File is incomplete.";
191
        return;
188
        return;
192
    }
189
    }*/
193
    toread = (input->size() > 0) ?(int32_t)input->size() :10000000;
190
    
194
    size = input->read(data, toread, toread);
191
    // stop the max block number guessing
195
    input->reset(0);
192
    // check for (nBat - 1) * 128 * 512 <= input-size() < nbat * 128 * 512
196
    if (size != input->size()) {
193
    // can there be a totally empty bat? (only -1), what happens with file size
194
    int32_t minSize = (nBat - 1) * 128 * 512;
195
    int32_t maxSize = nBat * 128 * 512; // +64k
196
197
    // we still have a 64k possible error window
198
    size = input->read(data, maxSize, maxSize);
199
    if (size < minSize) {
200
        fprintf(stderr, "minSize: %d vs. size %d \n", minSize, size);
197
        stream->m_status = Error;
201
        stream->m_status = Error;
198
        stream->m_error
202
        stream->m_error
199
            = string("File cannot be read completely: ")+input->error();
203
            = string("File cannot be read completely: ")+input->error();
200
        return;
204
        return;
201
    }
205
    }
202
    maxindex = size/512-2;
206
    input->reset(0);
207
208
    maxindex = size/512-2; // -1 -> header; -2 -> ?
203
209
204
    // read any remaining BAT entries from XBAT blocks
210
    // read any remaining BAT entries from XBAT blocks
205
    xBatOffset = 512 + 512 * xBatOffset;
211
    xBatOffset = 512 + 512 * xBatOffset;
Lines 211-216 OleInputStream::Private::Private(OleInputStream* s, InputStream* input) Link Here
211
        xBatOffset = 512+512*readLittleEndianInt32(data + 508 + xBatOffset);
217
        xBatOffset = 512+512*readLittleEndianInt32(data + 508 + xBatOffset);
212
    }
218
    }
213
219
220
// check last sector for no of remaining secIDS
214
    // print all bat blocks
221
    // print all bat blocks
215
/*    for (size_t i = 0; i<batIndex.size(); ++i) {
222
/*    for (size_t i = 0; i<batIndex.size(); ++i) {
216
        const char* b = data+(1+batIndex[i])*512;
223
        const char* b = data+(1+batIndex[i])*512;

Return to bug 354193