MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / Inflate

Method Inflate

libi2pd/Gzip.cpp:33–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 }
32
33 size_t GzipInflator::Inflate (const uint8_t * in, size_t inLen, uint8_t * out, size_t outLen)
34 {
35 if (inLen < 23) return 0;
36 if (in[10] == 0x01) // non compressed
37 {
38 size_t len = bufle16toh (in + 11);
39 if (len + 23 < inLen)
40 {
41 LogPrint (eLogError, "Gzip: Incorrect length");
42 return 0;
43 }
44 if (len > outLen) len = outLen;
45 memcpy (out, in + 15, len);
46 return len;
47 }
48 else
49 {
50 if (m_IsDirty) inflateReset (&m_Inflator);
51 m_IsDirty = true;
52 m_Inflator.next_in = const_cast<uint8_t *>(in);
53 m_Inflator.avail_in = inLen;
54 m_Inflator.next_out = out;
55 m_Inflator.avail_out = outLen;
56 int err;
57 if ((err = inflate (&m_Inflator, Z_NO_FLUSH)) == Z_STREAM_END)
58 return outLen - m_Inflator.avail_out;
59 // else
60 if (err)
61 LogPrint (eLogError, "Gzip: Inflate error ", err);
62 return 0;
63 }
64 }
65
66 void GzipInflator::Inflate (const uint8_t * in, size_t inLen, std::ostream& os)
67 {

Callers 5

MakeRequestMethod · 0.80
ExtractRouterInfoMethod · 0.80

Calls 3

bufle16tohFunction · 0.85
LogPrintFunction · 0.85
writeMethod · 0.80

Tested by

no test coverage detected