From: Apple Date: Tue, 16 Oct 2001 02:20:35 +0000 (+0000) Subject: Security-29.tar.gz X-Git-Tag: mac-os-x-1011^0 X-Git-Url: https://git.saurik.com/apple/security.git/commitdiff_plain/ded8f8e2930c4e5d6e866d59fc94c6b179af527c?ds=inline Security-29.tar.gz --- diff --git a/AppleCSP/CVSVersionInfo.txt b/AppleCSP/CVSVersionInfo.txt index d3c98a4f..076788a3 100644 --- a/AppleCSP/CVSVersionInfo.txt +++ b/AppleCSP/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:47 mb Exp $ -# $Name: Security-28 $ +# $Name: Security-29 $ ProjectName: AppleCSP ProjectVersion: 16 diff --git a/AppleCSPDL/CVSVersionInfo.txt b/AppleCSPDL/CVSVersionInfo.txt index 126aac7e..52cd7d48 100644 --- a/AppleCSPDL/CVSVersionInfo.txt +++ b/AppleCSPDL/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:51 mb Exp $ -# $Name: Security-28 $ +# $Name: Security-29 $ ProjectName: AppleCSPDL ProjectVersion: 15 diff --git a/AppleDL/CVSVersionInfo.txt b/AppleDL/CVSVersionInfo.txt index 7f386aa1..08547aba 100644 --- a/AppleDL/CVSVersionInfo.txt +++ b/AppleDL/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:52 mb Exp $ -# $Name: Security-28 $ +# $Name: Security-29 $ ProjectName: AppleDL ProjectVersion: 13 diff --git a/AppleX509CL/CVSVersionInfo.txt b/AppleX509CL/CVSVersionInfo.txt index a1de6b38..aa290af3 100644 --- a/AppleX509CL/CVSVersionInfo.txt +++ b/AppleX509CL/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:52 mb Exp $ -# $Name: Security-28 $ +# $Name: Security-29 $ ProjectName: AppleX509CL ProjectVersion: 3 diff --git a/AppleX509TP/CVSVersionInfo.txt b/AppleX509TP/CVSVersionInfo.txt index 12b4a6b9..75e0c334 100644 --- a/AppleX509TP/CVSVersionInfo.txt +++ b/AppleX509TP/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:53 mb Exp $ -# $Name: Security-28 $ +# $Name: Security-29 $ ProjectName: AppleX509TP ProjectVersion: 3 diff --git a/CVSVersionInfo.txt b/CVSVersionInfo.txt index 231f8aee..4b0e0ddb 100644 --- a/CVSVersionInfo.txt +++ b/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit -# $Id: CVSVersionInfo.txt,v 1.22 2001/09/11 00:42:18 mb Exp $ -# $Name: Security-28 $ +# $Id: CVSVersionInfo.txt,v 1.23 2001/10/16 02:20:35 mb Exp $ +# $Name: Security-29 $ ProjectName: Security -ProjectVersion: 28 +ProjectVersion: 29 diff --git a/Network/http-protocol.cpp b/Network/http-protocol.cpp index 814d911e..53e7806d 100644 --- a/Network/http-protocol.cpp +++ b/Network/http-protocol.cpp @@ -290,14 +290,17 @@ void HTTPProtocol::HTTPConnection::transit(Event event, char *input, size_t leng } } // no transfer-encoding (or transfer-encoding: identity): big gulp mode + state = readWholeBody; if (const char *lengthArg = headers().find("Content-Length")) { size_t length = strtol(lengthArg, NULL, 10); sink().setSize(length); - mode(sink(), length); - } else { + if (length > 0) + mode(sink(), length); + else // null body, already done + finish(); + } else { // read until EOI mode(sink()); } - state = readWholeBody; } break; } @@ -354,7 +357,7 @@ void HTTPProtocol::HTTPConnection::transit(Event event, char *input, size_t leng { // the only asynchronous event in idle mode is a connection drop debug("http", - "event %d while idle; destroying connection", event); + "%p event %d while idle; destroying connection", this, event); abort(); state = dead; } @@ -373,10 +376,11 @@ void HTTPProtocol::HTTPConnection::transitError(const CssmCommonError &error) void HTTPProtocol::HTTPConnection::finish() { + flushInput(); // clear excess garbage input (resynchronize) chooseRetain(); // shall we keep the Connection? - Connection::finish(); // finish this transfer mode(lineInput); // ensure valid input mode state = idle; // idle state + Connection::finish(); // finish this transfer } @@ -476,8 +480,10 @@ Transfer::ResultClass HTTPProtocol::HTTPTransfer::resultClass() const if (mResultClass != unclassifiedFailure) return mResultClass; // preclassified unsigned int code = httpResponseCode(); - if (code == 401 || code == 407) // auth or proxy auth required + if (code == 401 || code == 407 || code == 305) // auth or proxy auth required return authorizationFailure; + else if (code / 100 == 3) // redirect (interpreted as success) + return success; else if (code / 100 == 2) // success codes return success; else // when in doubt, blame the remote end :-) diff --git a/Network/xfercore.cpp b/Network/xfercore.cpp index 6e9fcbda..5b5dca2a 100644 --- a/Network/xfercore.cpp +++ b/Network/xfercore.cpp @@ -194,6 +194,21 @@ void TransferEngine::Client::startOutput() } +// +// Discard any data still in the input buffer. +// This is used to cope with unexpected garbage (protocol violations +// from the server), and shouldn't be used indiscriminately. +// +void TransferEngine::Client::flushInput() +{ + if (!mReadBuffer.isEmpty()) { + debug("engineio", "flushing %ld bytes of input", mReadBuffer.length()); + mReadBuffer.clear(); + mInputFlushed = true; // inhibit normal buffer ops + } +} + + // // Given that autoCopyOut mode is active, try to transfer some bytes // into the write buffer. This is a lazy, fast push, suitable for tacking on @@ -272,8 +287,10 @@ void TransferEngine::Client::notify(int fd, Type type) this, fd, io.iocget(FIONREAD))); do { + mInputFlushed = false; // preset normal + //@@@ break out after partial buffer to give Equal Time to other transfers? good idea?! - if (mReadBuffer.read(*this) == 0) { + if (!atEnd() && mReadBuffer.read(*this) == 0 && !atEnd()) { mReadBuffer.read(*this, true); } @@ -286,7 +303,8 @@ void TransferEngine::Client::notify(int fd, Type type) rawInputTransit(); break; case lineInput: - lineInputTransit(); + if (!lineInputTransit()) + return; // no full line; try again later break; case autoReadInput: autoReadInputTransit(); @@ -314,7 +332,7 @@ void TransferEngine::Client::notify(int fd, Type type) assert(false); } if (!io) // client has unhooked; clear buffer and exit loop - mReadBuffer.clear(); + flushInput(); } while (!mReadBuffer.isEmpty()); //@@@ feed back for more output here? But also see comments above... //@@@ probably better to take the trip through the Selector @@ -334,10 +352,11 @@ void TransferEngine::Client::rawInputTransit() IFDEBUG(debug("engineio", "%p(%d) --> %d bytes RAW", this, fileDesc(), io.iocget(FIONREAD))); transit(inputAvailable, addr, length); - mReadBuffer.usePut(length); + if (!mInputFlushed) + mReadBuffer.useGet(length); } -void TransferEngine::Client::lineInputTransit() +bool TransferEngine::Client::lineInputTransit() { char *line; size_t length = mReadBuffer.length(); mReadBuffer.locateGet(line, length); @@ -345,7 +364,7 @@ void TransferEngine::Client::lineInputTransit() char *nl; for (nl = line; nl < line + length && *nl != '\n'; nl++) ; if (nl == line + length) // no end-of-line, wait for more - return; + return false; if (nl > line && nl[-1] == '\r') { // proper \r\n termination nl[-1] = '\0'; // terminate for transit convenience @@ -356,7 +375,9 @@ void TransferEngine::Client::lineInputTransit() debug("engineio", "%p(%d) [IMPROPER] --> %s", this, fileDesc(), line); transit(inputAvailable, line, nl - line); } - mReadBuffer.useGet(nl - line + 1); + if (!mInputFlushed) + mReadBuffer.useGet(nl - line + 1); + return true; } void TransferEngine::Client::autoReadInputTransit() @@ -369,7 +390,8 @@ void TransferEngine::Client::autoReadInputTransit() mReadBuffer.locateGet(data, length); debug("engineio", "%p(%d) --> %ld bytes autoReadInput", this, fileDesc(), length); mSink->consume(data, length); - mReadBuffer.useGet(length); + if (!mInputFlushed) + mReadBuffer.useGet(length); if (mResidualReadCount && (mResidualReadCount -= length) == 0) mMode = autoIODone; } diff --git a/Network/xfercore.h b/Network/xfercore.h index f1d2e8e4..8f24d1a3 100644 --- a/Network/xfercore.h +++ b/Network/xfercore.h @@ -98,6 +98,8 @@ public: void flushOutput(bool autoFlush = true); + void flushInput(); + void tickle(); private: @@ -105,7 +107,7 @@ public: private: void rawInputTransit(); - void lineInputTransit(); + bool lineInputTransit(); void autoReadInputTransit(); void startOutput(); @@ -119,6 +121,7 @@ public: size_t mResidualReadCount; // bytes left to autoReadInput (zero => unlimited) size_t mResidualWriteCount; // bytes left to autoCopyOut (zero => unlimited) bool mAutoFlush; // output auto-flush mode + bool mInputFlushed; // transit flushed input; do not complete buffer ops FileDesc io; diff --git a/SecureTransport/CVSVersionInfo.txt b/SecureTransport/CVSVersionInfo.txt index d0b1f63e..43df79bf 100644 --- a/SecureTransport/CVSVersionInfo.txt +++ b/SecureTransport/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:58 mb Exp $ -# $Name: Security-28 $ +# $Name: Security-29 $ ProjectName: SecureTransport ProjectVersion: 3 diff --git a/SecurityASN1/CVSVersionInfo.txt b/SecurityASN1/CVSVersionInfo.txt index bd0f26cb..7ee7abb9 100644 --- a/SecurityASN1/CVSVersionInfo.txt +++ b/SecurityASN1/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:59 mb Exp $ -# $Name: Security-28 $ +# $Name: Security-29 $ ProjectName: SecurityASN1 ProjectVersion: 6 diff --git a/SecuritySNACCRuntime/CVSVersionInfo.txt b/SecuritySNACCRuntime/CVSVersionInfo.txt index 01a08450..38480462 100644 --- a/SecuritySNACCRuntime/CVSVersionInfo.txt +++ b/SecuritySNACCRuntime/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:14:04 mb Exp $ -# $Name: Security-28 $ +# $Name: Security-29 $ ProjectName: SecuritySNACCRuntime ProjectVersion: 6.1 diff --git a/SecurityServer/CVSVersionInfo.txt b/SecurityServer/CVSVersionInfo.txt index 7ca8c83e..43fe21d6 100644 --- a/SecurityServer/CVSVersionInfo.txt +++ b/SecurityServer/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:14:00 mb Exp $ -# $Name: Security-28 $ +# $Name: Security-29 $ ProjectName: SecurityServer ProjectVersion: 17.1 diff --git a/cdsa/CVSVersionInfo.txt b/cdsa/CVSVersionInfo.txt index b0ee3400..5057f9e2 100644 --- a/cdsa/CVSVersionInfo.txt +++ b/cdsa/CVSVersionInfo.txt @@ -1,5 +1,5 @@ # Created and modified by checkpoint; do not edit # $Id: CVSVersionInfo.txt,v 1.1.1.1 2001/05/18 23:13:53 mb Exp $ -# $Name: Security-28 $ +# $Name: Security-29 $ ProjectName: cdsa ProjectVersion: 21