MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / DoProcessReply

Function DoProcessReply

extra/yassl/src/handshake.cpp:742–831  ·  view source on GitHub ↗

do process input requests, return 0 is done, 1 is call again to complete

Source from the content-addressed store, hash-verified

740
741// do process input requests, return 0 is done, 1 is call again to complete
742int DoProcessReply(SSL& ssl)
743{
744 uint ready = ssl.getSocket().get_ready();
745 if (!ready)
746 ready= 64;
747
748 // add buffered data if its there
749 input_buffer* buffered = ssl.useBuffers().TakeRawInput();
750 uint buffSz = buffered ? buffered->get_size() : 0;
751 input_buffer buffer(buffSz + ready);
752 if (buffSz) {
753 buffer.assign(buffered->get_buffer(), buffSz);
754 ysDelete(buffered);
755 buffered = 0;
756 }
757
758 // add new data
759 uint read = ssl.useSocket().receive(buffer.get_buffer() + buffSz, ready);
760 if (read == static_cast<uint>(-1)) {
761 ssl.SetError(receive_error);
762 return 0;
763 }
764 buffer.add_size(read);
765 uint offset = 0;
766 const MessageFactory& mf = ssl.getFactory().getMessage();
767
768 // old style sslv2 client hello?
769 if (ssl.getSecurity().get_parms().entity_ == server_end &&
770 ssl.getStates().getServer() == clientNull)
771 if (buffer.peek() != handshake) {
772 ProcessOldClientHello(buffer, ssl);
773 if (ssl.GetError())
774 return 0;
775 }
776
777 while(!buffer.eof()) {
778 // each record
779 RecordLayerHeader hdr;
780 bool needHdr = false;
781
782 if (static_cast<uint>(RECORD_HEADER) > buffer.get_remaining())
783 needHdr = true;
784 else {
785 buffer >> hdr;
786 ssl.verifyState(hdr);
787 }
788
789 if (ssl.GetError())
790 return 0;
791
792 // make sure we have enough input in buffer to process this record
793 if (needHdr || hdr.length_ > buffer.get_remaining()) {
794 // put header in front for next time processing
795 uint extra = needHdr ? 0 : RECORD_HEADER;
796 uint sz = buffer.get_remaining() + extra;
797 ssl.useBuffers().SetRawInput(NEW_YS input_buffer(sz,
798 buffer.get_buffer() + buffer.get_current() - extra, sz));
799 return 1;

Callers 1

processReplyFunction · 0.85

Calls 15

ysDeleteFunction · 0.85
ProcessOldClientHelloFunction · 0.85
decrypt_messageFunction · 0.85
get_readyMethod · 0.80
TakeRawInputMethod · 0.80
get_sizeMethod · 0.80
receiveMethod · 0.80
add_sizeMethod · 0.80
get_parmsMethod · 0.80
peekMethod · 0.80
get_remainingMethod · 0.80
verifyStateMethod · 0.80

Tested by

no test coverage detected