git-svn-id: svn://db.shs.com.ru/pip@783 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -141,12 +141,21 @@ void PIStreamPacker::received(const PIByteArray & data) {
|
|||||||
if (packet.size_s() == packet_size) {
|
if (packet.size_s() == packet_size) {
|
||||||
PIByteArray cd;
|
PIByteArray cd;
|
||||||
if (crypt_frag) {
|
if (crypt_frag) {
|
||||||
|
//piCout << "decrypt frags ..." << packet_size;
|
||||||
while (packet.size_s() >= 4) {
|
while (packet.size_s() >= 4) {
|
||||||
|
//piCout << "decrypt frags take data ...";
|
||||||
PIByteArray frag;
|
PIByteArray frag;
|
||||||
|
//piCout << "decrypt frags take data done" << frag.size_s();
|
||||||
packet >> frag;
|
packet >> frag;
|
||||||
|
if (frag.isEmpty()) {
|
||||||
|
//piCout << "decrypt frags corrupt, break";
|
||||||
|
cd.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
cd.append(decryptData(frag));
|
cd.append(decryptData(frag));
|
||||||
//piCout << "crypt_frag receive add frag" << frag.size_s();
|
//piCout << "decrypt frags add" << frag.size_s();
|
||||||
}
|
}
|
||||||
|
//piCout << "decrypt frags done" << cd.size();
|
||||||
} else {
|
} else {
|
||||||
cd = decryptData(packet);
|
cd = decryptData(packet);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -375,8 +375,14 @@ std::ostream &operator <<(std::ostream & s, const PIByteArray & ba) {
|
|||||||
|
|
||||||
|
|
||||||
PIByteArray & operator >>(PIByteArray & s, PIByteArray & v) {
|
PIByteArray & operator >>(PIByteArray & s, PIByteArray & v) {
|
||||||
|
if (s.size_s() < 4) {
|
||||||
|
s.clear();
|
||||||
|
v.clear();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
assert(s.size_s() >= 4);
|
assert(s.size_s() >= 4);
|
||||||
int sz; s >> sz;
|
int sz = 0;
|
||||||
|
s >> sz;
|
||||||
if (sz > s.size_s()) {
|
if (sz > s.size_s()) {
|
||||||
piCout << "[PIByteArray] Warning: operator >> wants too much data, discard!";
|
piCout << "[PIByteArray] Warning: operator >> wants too much data, discard!";
|
||||||
s.clear();
|
s.clear();
|
||||||
@@ -384,7 +390,9 @@ PIByteArray & operator >>(PIByteArray & s, PIByteArray & v) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
v.resize(sz);
|
v.resize(sz);
|
||||||
if (sz > 0) memcpy(v.data(), s.data(), v.size());
|
if (sz > 0) {
|
||||||
s.remove(0, v.size());
|
memcpy(v.data(), s.data(), v.size());
|
||||||
|
s.remove(0, v.size());
|
||||||
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user