]> arthur.barton.de Git - netatalk.git/commitdiff
Merge master
authorFrank Lahm <franklahm@googlemail.com>
Sat, 8 Jan 2011 11:25:32 +0000 (12:25 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Sat, 8 Jan 2011 11:25:32 +0000 (12:25 +0100)
NEWS
libatalk/acl/cache.c

diff --git a/NEWS b/NEWS
index 60f20151ff2f87c8b268bc9e199a7625b34960c4..5d928fdace9e89ef7312c346a5aa5f5d982b3edc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,11 @@ Changes in 2.2alpha1
        use non-blocking IO and select instead.
 * REM: afile/achfile/apple_cp/apple_mv/apple_rm: use ad
 
+Changes in 2.1.6
+================
+
+* FIX: afpd: Fix for LDAP user cache corruption
+
 Changes in 2.1.5
 ================
 
index 60ae653a44b6cd1e832565d344f3c3455395dfc7..790e8c7ff69a6e7c21f869f867db197248499e7e 100644 (file)
@@ -119,7 +119,6 @@ int add_cachebyname( const char *inname, const uuidp_t inuuid, const uuidtype_t
     char *name = NULL;
     unsigned char *uuid;
     cacheduser_t *cacheduser = NULL;
-    cacheduser_t *entry;
     unsigned char hash;
 
 #ifdef DEBUG
@@ -162,15 +161,14 @@ int add_cachebyname( const char *inname, const uuidp_t inuuid, const uuidtype_t
     /* get hash */
     hash = hashstring((unsigned char *)name);
 
-    /* insert cache entry into cache array */
-    if (namecache[hash] == NULL) { /* this queue is empty */
+    /* insert cache entry into cache array at head of queue */
+    if (namecache[hash] == NULL) {
+        /* this queue is empty */
+        namecache[hash] = cacheduser;
+    } else {
+        cacheduser->next = namecache[hash];
+        namecache[hash]->prev = cacheduser;
         namecache[hash] = cacheduser;
-    } else {            /* queue is not empty, search end of queue*/
-        entry = namecache[hash];
-        while( entry->next != NULL)
-            entry = entry->next;
-        cacheduser->prev = entry;
-        entry->next = cacheduser;
     }
 
 cleanup:
@@ -205,7 +203,7 @@ int search_cachebyname( const char *name, uuidtype_t type, unsigned char *uuid)
 
     hash = hashstring((unsigned char *)name);
 
-    if (! namecache[hash])
+    if (namecache[hash] == NULL)
         return -1;
 
     entry = namecache[hash];
@@ -217,9 +215,14 @@ int search_cachebyname( const char *name, uuidtype_t type, unsigned char *uuid)
             if ((tim - entry->creationtime) > CACHESECONDS) {
                 LOG(log_debug, logtype_default, "search_cachebyname: expired: name:\'%s\' in queue {%d}", entry->name, hash);
                 /* remove item */
-                if (entry->prev) /* 2nd to last in queue */
+                if (entry->prev) {
+                    /* 2nd to last in queue */
                     entry->prev->next = entry->next;
-                else  { /* queue head */
+                    if (entry->next)
+                        /* not the last element */
+                        entry->next->prev = entry->prev;
+                } else  {
+                    /* queue head */
                     if ((namecache[hash] = entry->next) != NULL)
                         namecache[hash]->prev = NULL;
                 }
@@ -271,9 +274,14 @@ int search_cachebyuuid( uuidp_t uuidp, char **name, uuidtype_t *type) {
             tim = time(NULL);
             if ((tim - entry->creationtime) > CACHESECONDS) {
                 LOG(log_debug, logtype_default, "search_cachebyuuid: expired: name:\'%s\' in queue {%d}", entry->name, hash);
-                if (entry->prev) /* 2nd to last in queue */
+                if (entry->prev) {
+                    /* 2nd to last in queue */
                     entry->prev->next = entry->next;
-                else { /* queue head  */
+                    if (entry->next)
+                        /* not the last element */
+                        entry->next->prev = entry->prev;
+                } else {
+                    /* queue head  */
                     if ((uuidcache[hash] = entry->next) != NULL)
                         uuidcache[hash]->prev = NULL;
                 }
@@ -352,15 +360,14 @@ int add_cachebyuuid( uuidp_t inuuid, const char *inname, uuidtype_t type, const
     /* get hash */
     hash = hashuuid(uuid);
 
-    /* insert cache entry into cache array */
-    if (uuidcache[hash] == NULL) { /* this queue is empty */
+    /* insert cache entry into cache array at head of queue */
+    if (uuidcache[hash] == NULL) {
+        /* this queue is empty */
+        uuidcache[hash] = cacheduser;
+    } else {
+        cacheduser->next = uuidcache[hash];
+        uuidcache[hash]->prev = cacheduser;
         uuidcache[hash] = cacheduser;
-    } else {            /* queue is not empty, search end of queue*/
-        entry = uuidcache[hash];
-        while( entry->next != NULL)
-            entry = entry->next;
-        cacheduser->prev = entry;
-        entry->next = cacheduser;
     }
 
 cleanup: