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

svn author wk cvs at cvs.gnupg.org
Thu Jul 2 10:15:41 CEST 2009


Author: wk
Date: 2009-07-02 10:15:41 +0200 (Thu, 02 Jul 2009)
New Revision: 309

Modified:
   trunk/NEWS
   trunk/src/ChangeLog
   trunk/src/dn.c
   trunk/src/util.c
   trunk/src/util.h
Log:
Allow mixed cased names in DNs.


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2009-07-01 14:42:34 UTC (rev 308)
+++ trunk/src/ChangeLog	2009-07-02 08:15:41 UTC (rev 309)
@@ -1,3 +1,8 @@
+2009-07-02  Werner Koch  <wk at g10code.com>
+
+	* util.c (_ksba_ascii_memcasecmp, ascii_toupper): New.
+	* dn.c (parse_rdn): Use it
+
 2009-07-01  Werner Koch  <wk at g10code.com>
 
 	* dn.c (oid_name_tbl): Add dotted string representation of OIDs.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2009-07-01 14:42:34 UTC (rev 308)
+++ trunk/NEWS	2009-07-02 08:15:41 UTC (rev 309)
@@ -4,7 +4,9 @@
  * Detect overflow while parsing OIDs.  Map BER encoded OIDs to well
    known names.
 
+ * Allow mixed case names in DNs.
 
+
 Noteworthy changes in version 1.0.6 (2009-06-05)
 ------------------------------------------------
 

Modified: trunk/src/dn.c
===================================================================
--- trunk/src/dn.c	2009-07-01 14:42:34 UTC (rev 308)
+++ trunk/src/dn.c	2009-07-02 08:15:41 UTC (rev 309)
@@ -984,7 +984,7 @@
       for (i=0; oid_name_tbl[i].name; i++)
         {
           if ( n == strlen (oid_name_tbl[i].name)
-               && !memcmp (string, oid_name_tbl[i].name, n))
+               && !ascii_memcasecmp (string, oid_name_tbl[i].name, n))
             break;
         }
       if (!oid_name_tbl[i].name)

Modified: trunk/src/util.c
===================================================================
--- trunk/src/util.c	2009-07-01 14:42:34 UTC (rev 308)
+++ trunk/src/util.c	2009-07-02 08:15:41 UTC (rev 309)
@@ -1,5 +1,5 @@
 /* util.c
- *      Copyright (C) 2001 g10 Code GmbH
+ *      Copyright (C) 2001, 2009 g10 Code GmbH
  *
  * This file is part of KSBA.
  *
@@ -222,3 +222,29 @@
 }
 #endif
 
+
+static inline int 
+ascii_toupper (int c)
+{
+  if (c >= 'a' && c <= 'z')
+    c &= ~0x20;
+  return c;
+}
+
+
+int
+_ksba_ascii_memcasecmp (const void *a_arg, const void *b_arg, size_t n)
+{
+  const char *a = a_arg;
+  const char *b = b_arg;
+
+  if (a == b)
+    return 0;
+  for ( ; n; n--, a++, b++ )
+    {
+      if (*a != *b && ascii_toupper (*a) != ascii_toupper (*b))
+        return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b));
+    }
+  return 0;
+}
+

Modified: trunk/src/util.h
===================================================================
--- trunk/src/util.h	2009-07-01 14:42:34 UTC (rev 308)
+++ trunk/src/util.h	2009-07-02 08:15:41 UTC (rev 309)
@@ -1,5 +1,5 @@
 /* util.h 
- *      Copyright (C) 2001 g10 Code GmbH
+ *      Copyright (C) 2001, 2009 g10 Code GmbH
  *
  * This file is part of KSBA.
  *
@@ -84,6 +84,9 @@
 #define stpcpy(a,b) _ksba_stpcpy ((a), (b))
 #endif
 
+int _ksba_ascii_memcasecmp (const void *a_arg, const void *b_arg, size_t n);
+#define ascii_memcasecmp(a,b,n) _ksba_ascii_memcasecmp ((a),(b),(n))
+
 /* some macros to replace ctype ones and avoid locale problems */
 #define spacep(p)   (*(p) == ' ' || *(p) == '\t')
 #define digitp(p)   (*(p) >= '0' && *(p) <= '9')




More information about the Gnupg-commits mailing list