OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Various SSL functions. | 2 * Various SSL functions. |
3 * | 3 * |
4 * ***** BEGIN LICENSE BLOCK ***** | 4 * ***** BEGIN LICENSE BLOCK ***** |
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
6 * | 6 * |
7 * The contents of this file are subject to the Mozilla Public License Version | 7 * The contents of this file are subject to the Mozilla Public License Version |
8 * 1.1 (the "License"); you may not use this file except in compliance with | 8 * 1.1 (the "License"); you may not use this file except in compliance with |
9 * the License. You may obtain a copy of the License at | 9 * the License. You may obtain a copy of the License at |
10 * http://www.mozilla.org/MPL/ | 10 * http://www.mozilla.org/MPL/ |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 ssl_Do1stHandshake(sslSocket *ss) | 112 ssl_Do1stHandshake(sslSocket *ss) |
113 { | 113 { |
114 int rv = SECSuccess; | 114 int rv = SECSuccess; |
115 int loopCount = 0; | 115 int loopCount = 0; |
116 | 116 |
117 do { | 117 do { |
118 PORT_Assert(ss->opt.noLocks || ssl_Have1stHandshakeLock(ss) ); | 118 PORT_Assert(ss->opt.noLocks || ssl_Have1stHandshakeLock(ss) ); |
119 PORT_Assert(ss->opt.noLocks || !ssl_HaveRecvBufLock(ss)); | 119 PORT_Assert(ss->opt.noLocks || !ssl_HaveRecvBufLock(ss)); |
120 PORT_Assert(ss->opt.noLocks || !ssl_HaveXmitBufLock(ss)); | 120 PORT_Assert(ss->opt.noLocks || !ssl_HaveXmitBufLock(ss)); |
121 PORT_Assert(ss->opt.noLocks || !ssl_HaveSSL3HandshakeLock(ss)); | 121 PORT_Assert(ss->opt.noLocks || !ssl_HaveSSL3HandshakeLock(ss)); |
122 | 122 » |
123 if (ss->handshake == 0) { | 123 if (ss->handshake == 0) { |
124 /* Previous handshake finished. Switch to next one */ | 124 /* Previous handshake finished. Switch to next one */ |
125 ss->handshake = ss->nextHandshake; | 125 ss->handshake = ss->nextHandshake; |
126 ss->nextHandshake = 0; | 126 ss->nextHandshake = 0; |
127 } | 127 } |
128 if (ss->handshake == 0) { | 128 if (ss->handshake == 0) { |
129 /* Previous handshake finished. Switch to security handshake */ | 129 /* Previous handshake finished. Switch to security handshake */ |
130 ss->handshake = ss->securityHandshake; | 130 ss->handshake = ss->securityHandshake; |
131 ss->securityHandshake = 0; | 131 ss->securityHandshake = 0; |
132 } | 132 } |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 { | 556 { |
557 int rv; | 557 int rv; |
558 int amount; | 558 int amount; |
559 int available; | 559 int available; |
560 | 560 |
561 ssl_GetRecvBufLock(ss); | 561 ssl_GetRecvBufLock(ss); |
562 | 562 |
563 available = ss->gs.writeOffset - ss->gs.readOffset; | 563 available = ss->gs.writeOffset - ss->gs.readOffset; |
564 if (available == 0) { | 564 if (available == 0) { |
565 /* Get some more data */ | 565 /* Get some more data */ |
566 » if (ss->version >= SSL_LIBRARY_VERSION_3_0) { | 566 if (ss->version >= SSL_LIBRARY_VERSION_3_0) { |
567 /* Wait for application data to arrive. */ | 567 /* Wait for application data to arrive. */ |
568 rv = ssl3_GatherAppDataRecord(ss, 0); | 568 rv = ssl3_GatherAppDataRecord(ss, 0); |
569 } else { | 569 } else { |
570 /* See if we have a complete record */ | 570 /* See if we have a complete record */ |
571 rv = ssl2_GatherRecord(ss, 0); | 571 rv = ssl2_GatherRecord(ss, 0); |
572 } | 572 } |
573 if (rv <= 0) { | 573 if (rv <= 0) { |
574 if (rv == 0) { | 574 if (rv == 0) { |
575 /* EOF */ | 575 /* EOF */ |
576 SSL_TRC(10, ("%d: SSL[%d]: ssl_recv EOF", | 576 SSL_TRC(10, ("%d: SSL[%d]: ssl_recv EOF", |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 SSL_TRC(30, ("%d: SSL[%d]: partial data ready, available=%d", | 608 SSL_TRC(30, ("%d: SSL[%d]: partial data ready, available=%d", |
609 SSL_GETPID(), ss->fd, available)); | 609 SSL_GETPID(), ss->fd, available)); |
610 } | 610 } |
611 | 611 |
612 /* Dole out clear data to reader */ | 612 /* Dole out clear data to reader */ |
613 amount = PR_MIN(len, available); | 613 amount = PR_MIN(len, available); |
614 PORT_Memcpy(out, ss->gs.buf.buf + ss->gs.readOffset, amount); | 614 PORT_Memcpy(out, ss->gs.buf.buf + ss->gs.readOffset, amount); |
615 if (!(flags & PR_MSG_PEEK)) { | 615 if (!(flags & PR_MSG_PEEK)) { |
616 ss->gs.readOffset += amount; | 616 ss->gs.readOffset += amount; |
617 } | 617 } |
618 PORT_Assert(ss->gs.readOffset <= ss->gs.writeOffset); | |
wtc
2012/03/21 01:22:07
Did you mean to add this assertion, or did you add
ekr
2012/03/21 01:36:40
I suspect that I added it for debugging and forgot
wtc
2012/03/21 02:12:01
I am not familiar with this code, but I suspect th
| |
618 rv = amount; | 619 rv = amount; |
619 | 620 |
620 SSL_TRC(30, ("%d: SSL[%d]: amount=%d available=%d", | 621 SSL_TRC(30, ("%d: SSL[%d]: amount=%d available=%d", |
621 SSL_GETPID(), ss->fd, amount, available)); | 622 SSL_GETPID(), ss->fd, amount, available)); |
622 PRINT_BUF(4, (ss, "DoRecv receiving plaintext:", out, amount)); | 623 PRINT_BUF(4, (ss, "DoRecv receiving plaintext:", out, amount)); |
623 | 624 |
624 done: | 625 done: |
625 ssl_ReleaseRecvBufLock(ss); | 626 ssl_ReleaseRecvBufLock(ss); |
626 return rv; | 627 return rv; |
627 } | 628 } |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1585 if (!ss) { | 1586 if (!ss) { |
1586 SSL_DBG(("%d: SSL[%d]: bad socket in SNISocketConfigHook", | 1587 SSL_DBG(("%d: SSL[%d]: bad socket in SNISocketConfigHook", |
1587 SSL_GETPID(), fd)); | 1588 SSL_GETPID(), fd)); |
1588 return SECFailure; | 1589 return SECFailure; |
1589 } | 1590 } |
1590 | 1591 |
1591 ss->sniSocketConfig = func; | 1592 ss->sniSocketConfig = func; |
1592 ss->sniSocketConfigArg = arg; | 1593 ss->sniSocketConfigArg = arg; |
1593 return SECSuccess; | 1594 return SECSuccess; |
1594 } | 1595 } |
OLD | NEW |