Skip HTTP chunk extension (if present). Towards 2.0.14.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 25 Feb 2004 12:59:56 +0000 (12:59 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 25 Feb 2004 12:59:56 +0000 (12:59 +0000)
CHANGELOG
configure.in
debian/changelog
include/yaz/yaz-version.h
src/comstack.c
src/zgdu.c
win/yaz.nsi
win/yaz.rc

index 72599fb..50b8760 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,7 @@
 Possible compatibility problems with earlier versions marked with '*'.
 
+Fixes for Chunked encoding. White space not ignored after length spec.
+
 Update NS and use default NS for SRW diagnostic elements.
 
 --- 2.0.13 2004/02/23
index a423cec..5801730 100644 (file)
@@ -1,8 +1,8 @@
 dnl YAZ Toolkit, Index Data 1994-2004
 dnl See the file LICENSE for details.
-dnl $Id: configure.in,v 1.129 2004-02-23 09:30:17 adam Exp $
+dnl $Id: configure.in,v 1.130 2004-02-25 12:59:56 adam Exp $
 AC_INIT(include/yaz/yaz-version.h)
-AM_INIT_AUTOMAKE(yaz, 2.0.13)
+AM_INIT_AUTOMAKE(yaz, 2.0.14)
 AM_MAINTAINER_MODE
 dnl
 AC_SUBST(READLINE_LIBS)
index 9e8abe8..95cb6c4 100644 (file)
@@ -1,3 +1,9 @@
+yaz (2.0.14-1) unstable; urgency=low
+
+  * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk>  Wed, 25 Feb 2004 13:58:34 +0100
+
 yaz (2.0.13-2) unstable; urgency=low
 
   * API version 2.0.13. Fix NS for diagnostic elements.
index 68b86ee..3c3afea 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2004, Index Data.
  * See the file LICENSE for details.
  *
- * $Id: yaz-version.h,v 1.38 2004-02-23 09:30:17 adam Exp $
+ * $Id: yaz-version.h,v 1.39 2004-02-25 12:59:56 adam Exp $
  */
 
 /*
@@ -12,8 +12,8 @@
 
 #include <yaz/yconfig.h>
 
-#define YAZ_VERSION "2.0.13"
-#define YAZ_VERSIONL 0x02000D
+#define YAZ_VERSION "2.0.14"
+#define YAZ_VERSIONL 0x02000E
 
 #define YAZ_DATE 1
 
index 96b841c..db7ea2a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2004, Index Data
  * See the file LICENSE for details.
  *
- * $Id: comstack.c,v 1.5 2004-02-19 23:20:44 adam Exp $
+ * $Id: comstack.c,v 1.6 2004-02-25 12:59:56 adam Exp $
  */
 
 #include <string.h>
@@ -164,7 +164,7 @@ int cs_complete_auto(const unsigned char *buf, int len)
                        /* inside chunked body .. */
                         while(1)
                         {
-                            int chunk_len = 0;
+                            int j, chunk_len = 0;
                             i += 2;
 #if CHUNK_DEBUG
 /* debugging */
@@ -177,6 +177,7 @@ int cs_complete_auto(const unsigned char *buf, int len)
                                 printf (">>>\n");
                             }
 #endif
+                           /* read chunk length */
                             while (1)
                                 if (i >= len-2) {
 #if CHUNK_DEBUG
@@ -196,32 +197,41 @@ int cs_complete_auto(const unsigned char *buf, int len)
                                         (buf[i++] - ('a'-10));
                                 else
                                     break;
-                            if (buf[i] != '\r' || buf[i+1] != '\n' ||
-                                chunk_len < 0)
-                                return i+2;    /* bad. stop now */
+                           /* move forward until CRLF - skip chunk ext */
+                           j = 0;
+                           while (buf[i] != '\r' && buf[i+1] != '\n')
+                           {
+                               if (i >= len-2)
+                                   return 0;   /* need more buffer .. */
+                               if (++j > 1000)
+                                   return i; /* enough.. stop */
+                               i++;
+                           }
+                           /* got CRLF */
 #if CHUNK_DEBUG
                            printf ("XXXXXX chunk_len=%d\n", chunk_len);
 #endif                     
+                           if (chunk_len < 0)
+                               return i+2;    /* bad chunk_len */
                             if (chunk_len == 0)
-                            {
-                                /* consider trailing headers .. */
-                                while(i <= len-4)
-                                {
-                                    if (buf[i] == '\r' &&  buf[i+1] == '\n' &&
-                                        buf[i+2] == '\r' && buf[i+3] == '\n')
-                                        if (len >= i+4)
-                                            return i+4;
-                                    i++;
-                                }
+                               break;
+                            i += chunk_len+2;
+                        }
+                       /* consider trailing headers .. */
+                       while(i <= len-4)
+                       {
+                           if (buf[i] == '\r' &&  buf[i+1] == '\n' &&
+                               buf[i+2] == '\r' && buf[i+3] == '\n')
+                               if (len >= i+4)
+                                   return i+4;
+                           i++;
+                       }
 #if CHUNK_DEBUG
 /* debugging */
-                                printf ("XXXXXXXXX not there yet 2\n");
-                                printf ("i=%d len=%d\n", i, len);
+                       printf ("XXXXXXXXX not there yet 2\n");
+                       printf ("i=%d len=%d\n", i, len);
 #endif
-                                return 0;
-                            }
-                            i += chunk_len+2;
-                        }
+                       return 0;
                     }
                     else
                     {   /* not chunked ; inside body */
index 15683d4..0469d5f 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 2002-2004, Index Data.
  * See the file LICENSE for details.
  *
- * $Id: zgdu.c,v 1.8 2004-02-25 10:37:02 adam Exp $
+ * $Id: zgdu.c,v 1.9 2004-02-25 12:59:56 adam Exp $
  */
 
 #include <ctype.h>
@@ -78,11 +78,12 @@ static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers,
     {
        int off = 0;
        
-       /* we know buffer will be smaller than o->size - i - 2*/
-       *content_buf = (char*) odr_malloc(o, o->size - i - 2);  
+       /* we know buffer will be smaller than o->size - i*/
+       *content_buf = (char*) odr_malloc(o, o->size - i);  
        
        while (1)
        {
+           /* chunk length .. */
            int chunk_len = 0;
            for (; i  < o->size-2; i++)
                if (isdigit(o->buf[i]))
@@ -96,14 +97,17 @@ static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers,
                        (o->buf[i] - ('a'-10));
                else
                    break;
-           if (i > o->size - 2)
-               break;
-           if (o->buf[i] != '\r' || o->buf[i+1] != '\n') 
-           {   /* chunk length must be followed by \r\n */
-               o->error = OHTTP;
-               return 0;
+           /* chunk extension ... */
+           while (o->buf[i] != '\r' && o->buf[i+1] != '\n')
+           {
+               if (i >= o->size-2)
+               {
+                   o->error = OHTTP;
+                   return 0;
+               }
+               i++;
            }
-           i += 2;
+           i += 2;  /* skip CRLF */
            if (chunk_len == 0)
                break;
            if (chunk_len < 0 || off + chunk_len > o->size)
@@ -111,8 +115,9 @@ static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers,
                o->error = OHTTP;
                return 0;
            }
+           /* copy chunk .. */
            memcpy (*content_buf + off, o->buf + i, chunk_len);
-           i += chunk_len;
+           i += chunk_len + 2; /* skip chunk+CRLF */
            off += chunk_len;
        }
        if (!off)
index fa0d30f..d7a35ae 100644 (file)
@@ -1,6 +1,6 @@
-; $Id: yaz.nsi,v 1.36 2004-02-23 09:30:18 adam Exp $
+; $Id: yaz.nsi,v 1.37 2004-02-25 12:59:57 adam Exp $
 
-!define VERSION "2.0.13"
+!define VERSION "2.0.14"
 
 Name "YAZ"
 Caption "Index Data YAZ ${VERSION} Setup"
index defe72d..03791b6 100644 (file)
@@ -54,8 +54,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 2,0,13,1
- PRODUCTVERSION 2,0,13,1
+ FILEVERSION 2,0,14,1
+ PRODUCTVERSION 2,0,14,1
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -73,14 +73,14 @@ BEGIN
             VALUE "Comments", "Z39.50 C Library\0"
             VALUE "CompanyName", "Index Data\0"
             VALUE "FileDescription", "YAZ Toolkit\0"
-            VALUE "FileVersion", "2, 0, 13, 1\0"
+            VALUE "FileVersion", "2, 0, 14, 1\0"
             VALUE "InternalName", "YAZ\0"
             VALUE "LegalCopyright", "Copyright © 1995-2004 Index Data\0"
             VALUE "LegalTrademarks", "\0"
             VALUE "OriginalFilename", "yaz.rc\0"
             VALUE "PrivateBuild", "\0"
             VALUE "ProductName", "Index Data YAZ Toolkit\0"
-            VALUE "ProductVersion", "2, 0, 13, 1\0"
+            VALUE "ProductVersion", "2, 0, 14, 1\0"
             VALUE "SpecialBuild", "\0"
         END
     END