FIX: fix some bugs to pass compfuzz · richox/libzling@3028e10 (original) (raw)

This repository was archived by the owner on Apr 26, 2021. It is now read-only.

File tree

1 file changed

lines changed

1 file changed

lines changed

Original file line number Diff line number Diff line change
@@ -192,8 +192,6 @@ int Encode(Inputter* inputter, Outputter* outputter, ActionHandler* action_handl
192 192 ilen += inputter->GetData(res.ibuf + ilen, kBlockSizeIn - ilen);
193 193 CHECK_IO_ERROR(inputter);
194 194 }
195 -memset(res.ibuf + ilen, 0, kSentinelLen);
196 -
197 195 res.lzencoder->Reset();
198 196
199 197 while (encpos < ilen) {
@@ -323,11 +321,13 @@ int Decode(Inputter* inputter, Outputter* outputter, ActionHandler* action_handl
323 321 rlen = inputter->GetUInt32(); CHECK_IO_ERROR(inputter);
324 322 olen = inputter->GetUInt32(); CHECK_IO_ERROR(inputter);
325 323
324 +if (rlen > kBlockSizeRolz |
325 +throw std::runtime_error("baidu::zling::Decode(): invalid block size.");
326 + }
326 327 for (int ooff = 0; !inputter->IsEnd() && ooff < olen; ) {
327 328 ooff += inputter->GetData(res.obuf + ooff, olen - ooff);
328 329 CHECK_IO_ERROR(inputter);
329 330 }
330 -memset(res.obuf + olen, 0, kSentinelLen);
331 331
332 332 // HUFFMAN DECODE
333 333 // ============================================================