~percona-core/percona-server/5.5

« back to all changes in this revision

Viewing changes to extra/yassl/src/handshake.cpp

  • Committer: Laurynas Biveinis
  • Date: 2014-09-25 11:15:38 UTC
  • mfrom: (698.1.1 merge-5.5.40)
  • Revision ID: laurynas.biveinis@percona.com-20140925111538-imh8ubwq91n3j5sp
AutomergeĀ lp:~laurynas-biveinis/percona-server/merge-5.5.40

Show diffs side-by-side

added added

removed removed

Lines of Context:
522
522
// some clients still send sslv2 client hello
523
523
void ProcessOldClientHello(input_buffer& input, SSL& ssl)
524
524
{
525
 
    if (input.get_remaining() < 2) {
 
525
    if (input.get_error() || input.get_remaining() < 2) {
526
526
        ssl.SetError(bad_input);
527
527
        return;
528
528
    }
549
549
 
550
550
    byte len[2];
551
551
 
552
 
    input.read(len, sizeof(len));
 
552
    len[0] = input[AUTO];
 
553
    len[1] = input[AUTO];
553
554
    ato16(len, ch.suite_len_);
554
555
 
555
 
    input.read(len, sizeof(len));
 
556
    len[0] = input[AUTO];
 
557
    len[1] = input[AUTO];
556
558
    uint16 sessionLen;
557
559
    ato16(len, sessionLen);
558
560
    ch.id_len_ = sessionLen;
559
561
 
560
 
    input.read(len, sizeof(len));
 
562
    len[0] = input[AUTO];
 
563
    len[1] = input[AUTO];
561
564
    uint16 randomLen;
562
565
    ato16(len, randomLen);
563
566
 
564
 
    if (ch.suite_len_ > MAX_SUITE_SZ || sessionLen > ID_LEN ||
565
 
                                        randomLen > RAN_LEN) {
 
567
    if (input.get_error() || ch.suite_len_ > MAX_SUITE_SZ ||
 
568
                             ch.suite_len_ > input.get_remaining() ||
 
569
                             sessionLen > ID_LEN || randomLen > RAN_LEN) {
566
570
        ssl.SetError(bad_input);
567
571
        return;
568
572
    }
580
584
    ch.suite_len_ = j;
581
585
 
582
586
    if (ch.id_len_)
583
 
        input.read(ch.session_id_, ch.id_len_);
 
587
        input.read(ch.session_id_, ch.id_len_);   // id_len_ from sessionLen
584
588
 
585
589
    if (randomLen < RAN_LEN)
586
590
        memset(ch.random_, 0, RAN_LEN - randomLen);
587
591
    input.read(&ch.random_[RAN_LEN - randomLen], randomLen);
588
592
 
589
 
 
590
593
    ch.Process(input, ssl);
591
594
}
592
595
 
787
790
            ssl.verifyState(hdr);
788
791
        }
789
792
 
 
793
        if (ssl.GetError())
 
794
            return 0;
 
795
 
790
796
        // make sure we have enough input in buffer to process this record
791
797
        if (needHdr || hdr.length_ > buffer.get_remaining()) {
792
798
            // put header in front for next time processing
799
805
 
800
806
        while (buffer.get_current() < hdr.length_ + RECORD_HEADER + offset) {
801
807
            // each message in record, can be more than 1 if not encrypted
 
808
            if (ssl.GetError())
 
809
                return 0;
 
810
 
802
811
            if (ssl.getSecurity().get_parms().pending_ == false) { // cipher on
803
812
                // sanity check for malicious/corrupted/illegal input
804
813
                if (buffer.get_remaining() < hdr.length_) {