mirror of https://github.com/aria2/aria2
Use std::search instead of creating temporary std::string.
parent
72a1847ba8
commit
2ca98cc428
|
@ -326,9 +326,10 @@ bool MSEHandshake::findInitiatorVCMarker()
|
||||||
{
|
{
|
||||||
// 616 is synchronization point of initiator
|
// 616 is synchronization point of initiator
|
||||||
// find vc
|
// find vc
|
||||||
std::string buf(&rbuf_[0], &rbuf_[rbufLength_]);
|
unsigned char* ptr =
|
||||||
std::string vc(&initiatorVCMarker_[0], &initiatorVCMarker_[VC_LENGTH]);
|
std::search(&rbuf_[0], &rbuf_[rbufLength_],
|
||||||
if((markerIndex_ = buf.find(vc)) == std::string::npos) {
|
&initiatorVCMarker_[0], &initiatorVCMarker_[VC_LENGTH]);
|
||||||
|
if(ptr == &rbuf_[rbufLength_]) {
|
||||||
if(616-KEY_LENGTH <= rbufLength_) {
|
if(616-KEY_LENGTH <= rbufLength_) {
|
||||||
throw DL_ABORT_EX("Failed to find VC marker.");
|
throw DL_ABORT_EX("Failed to find VC marker.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -336,6 +337,7 @@ bool MSEHandshake::findInitiatorVCMarker()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
markerIndex_ = ptr-rbuf_;
|
||||||
A2_LOG_DEBUG(fmt("CUID#%lld - VC marker found at %lu",
|
A2_LOG_DEBUG(fmt("CUID#%lld - VC marker found at %lu",
|
||||||
cuid_,
|
cuid_,
|
||||||
static_cast<unsigned long>(markerIndex_)));
|
static_cast<unsigned long>(markerIndex_)));
|
||||||
|
@ -397,11 +399,11 @@ bool MSEHandshake::findReceiverHashMarker()
|
||||||
{
|
{
|
||||||
// 628 is synchronization limit of receiver.
|
// 628 is synchronization limit of receiver.
|
||||||
// find hash('req1', S), S is secret_.
|
// find hash('req1', S), S is secret_.
|
||||||
std::string buf(&rbuf_[0], &rbuf_[rbufLength_]);
|
|
||||||
unsigned char md[20];
|
unsigned char md[20];
|
||||||
createReq1Hash(md);
|
createReq1Hash(md);
|
||||||
std::string req1(&md[0], &md[sizeof(md)]);
|
unsigned char* ptr = std::search
|
||||||
if((markerIndex_ = buf.find(req1)) == std::string::npos) {
|
(&rbuf_[0], &rbuf_[rbufLength_], &md[0], &md[sizeof(md)]);
|
||||||
|
if(ptr == &rbuf_[rbufLength_]) {
|
||||||
if(628-KEY_LENGTH <= rbufLength_) {
|
if(628-KEY_LENGTH <= rbufLength_) {
|
||||||
throw DL_ABORT_EX("Failed to find hash marker.");
|
throw DL_ABORT_EX("Failed to find hash marker.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -409,6 +411,7 @@ bool MSEHandshake::findReceiverHashMarker()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
markerIndex_ = ptr-rbuf_;
|
||||||
A2_LOG_DEBUG(fmt("CUID#%lld - Hash marker found at %lu.",
|
A2_LOG_DEBUG(fmt("CUID#%lld - Hash marker found at %lu.",
|
||||||
cuid_,
|
cuid_,
|
||||||
static_cast<unsigned long>(markerIndex_)));
|
static_cast<unsigned long>(markerIndex_)));
|
||||||
|
|
Loading…
Reference in New Issue