[svn] ksba - r248 - in trunk: . src

svn author wk cvs at cvs.gnupg.org
Wed Jul 19 10:47:19 CEST 2006


Author: wk
Date: 2006-07-19 10:47:18 +0200 (Wed, 19 Jul 2006)
New Revision: 248

Modified:
   trunk/NEWS
   trunk/src/ChangeLog
   trunk/src/dn.c
   trunk/src/ocsp.c
Log:
BMPString fix.


Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2006-07-03 12:50:12 UTC (rev 247)
+++ trunk/NEWS	2006-07-19 08:47:18 UTC (rev 248)
@@ -1,8 +1,8 @@
 Noteworthy changes in version 0.9.16
 -------------------------------------------------
 
+ * Fixed a character set conversion bug in BMPStrings.
 
-
  * Interface changes relative to the 0.9.13 release:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ksba_dn_teststr                NEW

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2006-07-03 12:50:12 UTC (rev 247)
+++ trunk/src/ChangeLog	2006-07-19 08:47:18 UTC (rev 248)
@@ -1,3 +1,14 @@
+2006-07-19  Werner Koch  <wk at g10code.com>
+
+	* dn.c (put_stringbuf_mem_skip): New.
+	(append_quoted): New arg SKIP.  Changed all callers.
+	(append_ucs4_value, append_ucs2_value): Tell append_quoted to skip
+	the zero bytes we detected.
+
+2006-07-18  Werner Koch  <wk at g10code.com>
+
+	* dn.c (append_ucs2_value): Fixed second blank detection case.
+
 2006-07-03  Werner Koch  <wk at g10code.com>
 
 	* ksba.h, ksba.c (ksba_dn_teststr): New.

Modified: trunk/src/dn.c
===================================================================
--- trunk/src/dn.c	2006-07-03 12:50:12 UTC (rev 247)
+++ trunk/src/dn.c	2006-07-19 08:47:18 UTC (rev 248)
@@ -170,6 +170,43 @@
   sb->len += n;
 }
 
+static void
+put_stringbuf_mem_skip (struct stringbuf *sb, const char *text, size_t n,
+                        int skip)
+{
+  char *p;
+      
+  if (!skip)
+    {
+      put_stringbuf_mem (sb, text, n);
+      return;
+    }
+  if (sb->out_of_core)
+    return;
+
+  if (sb->len + n >= sb->size)
+    {
+      /* Note: we allocate too much here, but we don't care. */
+      sb->size += n + 100;
+      p = xtryrealloc (sb->buf, sb->size);
+      if ( !p)
+        {
+          sb->out_of_core = 1;
+          return;
+        }
+      sb->buf = p;
+    }
+  p = sb->buf+sb->len;
+  while (n > skip)
+    {
+      text += skip;
+      n -= skip;
+      *p++ = *text++;
+      n--;
+      sb->len++;
+    }
+}
+
 static char *
 get_stringbuf (struct stringbuf *sb)
 {
@@ -192,9 +229,11 @@
 /* This function is used for 1 byte encodings to insert any required
    quoting.  It does not do the quoting for a space or hash mark at
    the beginning of a string or a space as the last character of a
-   string */
+   string.  It will do steps of SKIP+1 characters, assuming that these
+   SKIP characters are null octets. */
 static void
-append_quoted (struct stringbuf *sb, const unsigned char *value, size_t length)
+append_quoted (struct stringbuf *sb, const unsigned char *value, size_t length,
+               int skip)
 {
   unsigned char tmp[4];
   const unsigned char *s = value;
@@ -202,16 +241,20 @@
 
   for (;;)
     {
-      for (value = s; n < length; n++, s++)
+      for (value = s; n+skip < length; n++, s++)
         {
+          s += skip;
+          n += skip;
           if (*s < ' ' || *s > 126 || strchr (",+\"\\<>;", *s) )
             break;
         }
 
       if (s != value)
-        put_stringbuf_mem (sb, value, s-value);
-      if (n==length)
+        put_stringbuf_mem_skip (sb, value, s-value, skip);
+      if (n+skip >= length)
         return; /* ready */
+      s += skip;
+      n += skip;
       if ( *s < ' ' || *s > 126 )
         {
           sprintf (tmp, "\\%02X", *s);
@@ -260,7 +303,7 @@
       for (value = s; n < length && !(*s & 0x80); n++, s++)
         ;
       if (s != value)
-        append_quoted (sb, value, s-value);
+        append_quoted (sb, value, s-value, 0);
       if (n==length)
         return; /* ready */
       assert ((*s & 0x80));
@@ -323,7 +366,7 @@
       for (value = s; n < length && !(*s & 0x80); n++, s++)
         ;
       if (s != value)
-        append_quoted (sb, value, s-value);
+        append_quoted (sb, value, s-value, 0);
       if (n==length)
         return; /* ready */
       assert ((*s & 0x80));
@@ -369,7 +412,7 @@
              && !s[0] && !s[1] && !s[2] && !(s[3] & 0x80); n += 4, s += 4)
         ;
       if (s != value)
-        append_quoted (sb, value, s-value);
+        append_quoted (sb, value, s-value, 3);
       if (n>=length)
         return; /* ready */
       if (n < 4)
@@ -443,7 +486,7 @@
       value += 2;
       length -= 2;
     }
-  if (length>3 && !value[0] && value[1] == ' ')
+  if (length>1 && !value[0] && value[1] == ' ')
     {
       tmp[0] = '\\';
       tmp[1] = ' ';
@@ -456,7 +499,7 @@
       for (value = s; n+1 < length && !s[0] && !(s[1] & 0x80); n += 2, s += 2)
         ;
       if (s != value)
-        append_quoted (sb, value, s-value);
+        append_quoted (sb, value, s-value, 1);
       if (n>=length)
         return; /* ready */
       if (n < 2)

Modified: trunk/src/ocsp.c
===================================================================
--- trunk/src/ocsp.c	2006-07-03 12:50:12 UTC (rev 247)
+++ trunk/src/ocsp.c	2006-07-19 08:47:18 UTC (rev 248)
@@ -319,7 +319,7 @@
    buffer NONCE of size NONCELEN.  Libksba may have an upper limit of
    the allowed size of the nonce; if the supplied nonce is larger it
    will be truncated and the actual used length of the nonce returned.
-   To detect the implementation limit (which should be sonsidred as a
+   To detect the implementation limit (which should be considered as a
    good suggestion), the function may be called with NULL for NONCE,
    in which case the maximal usable noncelength is returned. The
    function returns the length of the nonce which will be used. */
@@ -1358,7 +1358,7 @@
 
 /* Given the OCSP context and a binary reponse message of MSGLEN bytes
    in MSG, this fucntion parses the response and prepares it for
-   signature verification.  The status from the server is retruned in
+   signature verification.  The status from the server is returned in
    RESPONSE_STATUS and must be checked even if the fucntion returns
    without an error. */
 gpg_error_t
@@ -1380,7 +1380,7 @@
   ocsp->received_certs = NULL;
   ocsp->hash_length = 0;
 
-  /* Reset the fields used to track the reponse.  This is so that we
+  /* Reset the fields used to track the response.  This is so that we
      can use the parse function a second time for the same
      request. This is useful in case of a TryLater response status. */
   for (ri=ocsp->requestlist; ri; ri = ri->next)
@@ -1402,7 +1402,7 @@
       && ocsp->noncelen)
     {
       /* FIXME: Check that there is a received nonce and that it matches. */
-
+      /* If not status to KSBA_OCSP_RSPSTATUS_REPLAYED */
     }
 
 




More information about the Gnupg-commits mailing list