]> git.saurik.com Git - apple/security.git/commitdiff
Security-29.tar.gz mac-os-x-1011 mac-os-x-1012 v29
authorApple <opensource@apple.com>
Tue, 16 Oct 2001 02:20:35 +0000 (02:20 +0000)
committerApple <opensource@apple.com>
Tue, 16 Oct 2001 02:20:35 +0000 (02:20 +0000)
14 files changed:
AppleCSP/CVSVersionInfo.txt
AppleCSPDL/CVSVersionInfo.txt
AppleDL/CVSVersionInfo.txt
AppleX509CL/CVSVersionInfo.txt
AppleX509TP/CVSVersionInfo.txt
CVSVersionInfo.txt
Network/http-protocol.cpp
Network/xfercore.cpp
Network/xfercore.h
SecureTransport/CVSVersionInfo.txt
SecurityASN1/CVSVersionInfo.txt
SecuritySNACCRuntime/CVSVersionInfo.txt
SecurityServer/CVSVersionInfo.txt
cdsa/CVSVersionInfo.txt

index d3c98a4f14b4c5647a056b8ac44750dfcc1ec855..076788a3dfca8db8efad6949b3a3b0000e80af2f 100644 (file)
@@ -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
index 126aac7e0ed2257ba172884e8e12188393a6464e..52cd7d484fa7bd908d908a27ac3540c2c3e874d6 100644 (file)
@@ -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
index 7f386aa1271735e546caaeefa734ed91866ea3a5..08547abacd5bbdcb6e4c867b840b8deb13d4ce30 100644 (file)
@@ -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
index a1de6b38912c1fe5f1600fa37d0f0bffb7a0131a..aa290af3c96d9ad17c1d6c6e7bd9f97a93067c87 100644 (file)
@@ -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
index 12b4a6b98f2f836de6d81c93b44b4e074f1e138e..75e0c33473ffcae278a02af44be118d6d63c47cb 100644 (file)
@@ -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
index 231f8aeecb12731c6f354e3543235976295ed84b..4b0e0ddb04bb849a2a25c14af2b000a7099c99ce 100644 (file)
@@ -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
index 814d911e1d7c0b2b4be0f29a8f0b6239993215d9..53e7806d33fa5403f90a1742882973205be185a7 100644 (file)
@@ -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 :-)
index 6e9fcbdaeaacb06329abe9a0d8e0af2a7b4996ee..5b5dca2a16a4f6cda0537e52f419f83e5ef4ab48 100644 (file)
@@ -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<int>(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<int>(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;
 }
index f1d2e8e4748204993381c8fb33f9d41da452f06d..8f24d1a34fbcf65590d1f412be35948153b53103 100644 (file)
@@ -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;
         
index d0b1f63eeb98b51f504f6c5a3b644709e057eae1..43df79bf2ec58e76667ce5c83df6a5f367218a6d 100644 (file)
@@ -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
index bd0f26cb1c3e252d98c1af413669451cdc1a2857..7ee7abb9830edf49797db33a0ffcc63c270c8c5e 100644 (file)
@@ -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
index 01a084502fb7864ec4821059f61e97cb261eaa08..3848046242212b8198e1e553743e1993b3454ea1 100644 (file)
@@ -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
index 7ca8c83e0d1058d80f50263ea21ac552832effdd..43fe21d64a9594403f6758780b1043f6f1f53ca1 100644 (file)
@@ -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
index b0ee34004e227a33e8fcf9320638e9f2d064b039..5057f9e2579ae74574d72e51c1c3cf44721ba5f8 100644 (file)
@@ -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