unbreak broken fix
authorbrian <brian@brianweb.net>
Thu, 1 May 2008 17:10:42 +0000 (17:10 +0000)
committerbrian <brian@brianweb.net>
Thu, 1 May 2008 17:10:42 +0000 (17:10 +0000)
darcs-hash:20080501171042-24bed-011b2157a160c5cae07455c4ba55e0084ddb75c2.gz

src/org/ibex/net/SSL.java

index dc1c201..74c4105 100644 (file)
@@ -327,12 +327,13 @@ public class SSL extends Socket {
         if(buf[0] != 11) throw new Exn("expected a Certificate message");
         if((((buf[4]&0xff)<<16)|((buf[5]&0xff)<<8)|((buf[6]&0xff)<<0)) != buf.length-7) throw new Exn("size mismatch in Certificate message");
         int p;
-        int count;
+        int len,count;
         
         p = 7;
         count = 0;
-        while(p < buf.length - 3) {
-            p += 3 + ((buf[p+0]&0xff)<<16)|((buf[p+1]&0xff)<<8)|((buf[p+2]&0xff)<<0);
+        while(p < buf.length - 2) {
+            len = ((buf[p+0]&0xff)<<16)|((buf[p+1]&0xff)<<8)|((buf[p+2]&0xff)<<0);
+            p += 3 + len;
             count++;
         }
         if(count == 0) throw new Exn("server didn't provide any certificates");
@@ -340,7 +341,7 @@ public class SSL extends Socket {
         p = 7;
         count = 0;
         while(p < buf.length) {
-            int len = ((buf[p+0]&0xff)<<16)|((buf[p+1]&0xff)<<8)|((buf[p+2]&0xff)<<0);
+            len = ((buf[p+0]&0xff)<<16)|((buf[p+1]&0xff)<<8)|((buf[p+2]&0xff)<<0);
             p += 3;
             if(p + len > buf.length) throw new Exn("Certificate message cut short");
             certs[count++] = new X509.Certificate(new ByteArrayInputStream(buf,p,len));