windows-unicode-normalize-btree-20080511
authorJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 12 May 2008 04:02:28 +0000 (04:02 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Mon, 12 May 2008 04:02:28 +0000 (04:02 +0000)
LICENSE MIT

Attempt to normalize afs directory strings before inserting them into
the B+tree.

src/WINNT/afsd/cm_btree.c

index fc39c69..ee81843 100644 (file)
@@ -1853,10 +1853,21 @@ int cm_BPlusDirFoo(struct cm_scache *scp, struct cm_dirEntry *dep,
     keyT   key = {dep->name};
     dataT  data;
     char   shortName[13];
-
+    long   normalized_len;
+    char  *normalized_name=NULL;
     cm_SetFid(&data.fid, scp->fid.cell, scp->fid.volume, ntohl(dep->fid.vnode), ntohl(dep->fid.unique));
     data.longname = NULL;
 
+    normalized_len = cm_NormalizeUtf8String(dep->name, -1, NULL, 0);
+    if (normalized_len)
+        normalized_name = malloc(normalized_len);
+    if (normalized_name) {
+        cm_NormalizeUtf8String(dep->name, -1, normalized_name, normalized_len);
+        key.name = normalized_name;
+    } else {
+        key.name = dep->name;
+    }
+
     /* the Write lock is held in cm_BPlusDirBuildTree() */
     insert(scp->dirBplus, key, data);
     if (!cm_Is8Dot3(dep->name)) {
@@ -1871,6 +1882,9 @@ int cm_BPlusDirFoo(struct cm_scache *scp, struct cm_dirEntry *dep,
         insert(scp->dirBplus, key, data);
     }
 
+    if (normalized_name)
+        free(normalized_name);
+
 #ifdef BTREE_DEBUG
     findAllBtreeValues(scp->dirBplus);
 #endif