Fixed secio protocol request coming with length.

master
Jose Marcial Vieira Bisneto 2018-11-16 11:20:06 -03:00
parent f04fa5c9e5
commit b0b18632f9
No known key found for this signature in database
GPG Key ID: 103E935E7E6E831E
1 changed files with 7 additions and 2 deletions

View File

@ -43,8 +43,13 @@ int libp2p_secio_can_handle(const struct StreamMessage* msg) {
if (msg->data_size < 12)
return 0;
char* result = strnstr((char*)msg->data, protocol, msg->data_size);
if (result != NULL && result == (char*)msg->data)
return 1;
if (result != NULL) {
if (result == (char*)msg->data)
return 1;
// may have come with "protocol + LF" length in the first byte.
if (result == (char*)msg->data+1 && msg->data[0] == strlen(protocol)+1)
return 1;
}
return 0;
}