commit 0dc852d8217620557c32a2bef0c03f571617be42
parent b81940e5eb810331b4b3c7fc92aee3985d8664bb
Author: Alexander Burger <abu@software-lab.de>
Date: Tue, 20 Mar 2012 08:46:10 +0100
'httpGate' session bug (Firefox SSL connection problem)
Diffstat:
6 files changed, 34 insertions(+), 53 deletions(-)
diff --git a/CHANGES b/CHANGES
@@ -1,4 +1,5 @@
* XXmmm12 picoLisp-3.0.10
+ 'httpGate' session bug
Simplified 'sigio'
Volatile 'NIL' property
Bug in 'fold' (64-bit)
diff --git a/ersatz/picolisp.jar b/ersatz/picolisp.jar
Binary files differ.
diff --git a/lib/http.l b/lib/http.l
@@ -1,4 +1,4 @@
-# 04mar12abu
+# 20mar12abu
# (c) Software Lab. Alexander Burger
# *Home *Gate *Host *Port *Port1 *Port% *Http1 *Chunked
@@ -238,7 +238,11 @@
(use (L @X @Y Pil)
(setq *Http1 (format (car @H)) *Chunked (gt0 *Http1) Pil)
(if (index "~" @U)
- (setq *ConId (pack (head @ @U)) @U (cdr (nth @U @)))
+ (setq
+ *ConId (head @ @U)
+ @U (cdr (nth @U @))
+ *ConId
+ (pack (if (member "/" *ConId) (cdr @) *ConId)) )
(off *ConId) )
(while (setq L (line))
(cond
@@ -292,7 +296,7 @@
((match '(@N ~(chop "; filename=") . @V) @X)
(match '("\"" @N "\"") @N)
(match '("\"" @V "\"") @V)
- (if (_htSet @N (pack (stem @V '/ "\\")))
+ (if (_htSet @N (pack (stem @V "/" "\\")))
(let F (tmp @)
(unless (out F (echo (pack "^M^J" *MPartLim)))
(call 'rm "-f" F) ) )
diff --git a/src/httpGate.c b/src/httpGate.c
@@ -1,4 +1,4 @@
-/* 20oct11abu
+/* 20mar12abu
* (c) Software Lab. Alexander Burger
*/
@@ -42,47 +42,6 @@ static inline bool pre(char *p, char *s) {
return YES;
}
-static char *ses(char *buf, int port, int *len) {
- int np;
- char *p, *q;
-
- if (Http1 == 0)
- return buf;
- if (pre(buf, "GET /")) {
- np = (int)strtol(buf+5, &q, 10);
- if (q == buf+5 || *q != '/' || np < 1024 || np > 65535)
- return buf;
- p = q++ - 4;
- do
- if (*q < '0' || *q > '9')
- return buf;
- while (*++q != '~');
- if (np == port) {
- p[0] = 'G', p[1] = 'E', p[2] = 'T', p[3] = ' ';
- *len -= p - buf;
- return p;
- }
- return NULL;
- }
- if (pre(buf, "POST /")) {
- np = (int)strtol(buf+6, &q, 10);
- if (q == buf+6 || *q != '/' || np < 1024 || np > 65535)
- return buf;
- p = q++ - 5;
- do
- if (*q < '0' || *q > '9')
- return buf;
- while (*++q != '~');
- if (np == port) {
- p[0] = 'P', p[1] = 'O', p[2] = 'S', p[3] = 'T', p[4] = ' ';
- *len -= p - buf;
- return p;
- }
- return NULL;
- }
- return buf;
-}
-
static int slow(SSL *ssl, int fd, char *p, int cnt) {
int n;
@@ -92,6 +51,25 @@ static int slow(SSL *ssl, int fd, char *p, int cnt) {
return n;
}
+static int rdLine(SSL *ssl, int fd, char *p, int cnt) {
+ int n, len;
+
+ for (len = 0;;) {
+ if ((n = ssl? SSL_read(ssl, p, cnt) : read(fd, p, cnt)) <= 0) {
+ if (!n || errno != EINTR)
+ return 0;
+ }
+ else {
+ len += n;
+ if (memchr(p, '\n', n))
+ return len;
+ p += n;
+ if ((cnt -= n) == 0)
+ return 0;
+ }
+ }
+}
+
static void wrBytes(int fd, char *p, int cnt) {
int n;
@@ -207,10 +185,8 @@ int main(int ac, char *av[]) {
SSL_set_fd(ssl, cli);
if (SSL_accept(ssl) < 0)
return 1;
- n = SSL_read(ssl, buf, sizeof(buf));
}
- else
- n = read(cli, buf, sizeof(buf));
+ n = rdLine(ssl, cli, buf, sizeof(buf));
alarm(0);
if (n < 6)
return 1;
@@ -285,9 +261,9 @@ int main(int ac, char *av[]) {
alarm(420);
n = slow(ssl, cli, buf, sizeof(buf));
alarm(0);
- if (!n || !(p = ses(buf, port, &n)))
+ if (!n)
break;
- wrBytes(srv, p, n);
+ wrBytes(srv, buf, n);
}
shutdown(cli, SHUT_RD);
shutdown(srv, SHUT_WR);
diff --git a/src/vers.h b/src/vers.h
@@ -1 +1 @@
-static byte Version[4] = {3,0,9,5};
+static byte Version[4] = {3,0,9,6};
diff --git a/src64/version.l b/src64/version.l
@@ -1,6 +1,6 @@
-# 07mar12abu
+# 19mar12abu
# (c) Software Lab. Alexander Burger
-(de *Version 3 0 9 5)
+(de *Version 3 0 9 6)
# vi:et:ts=3:sw=3