diff options
Diffstat (limited to 'nscd')
-rw-r--r-- | nscd/nscd-client.h | 7 | ||||
-rw-r--r-- | nscd/nscd.h | 5 | ||||
-rw-r--r-- | nscd/nscd_helper.c | 3 |
3 files changed, 8 insertions, 7 deletions
diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h index f66a658d2a..81ca3d56b9 100644 --- a/nscd/nscd-client.h +++ b/nscd/nscd-client.h @@ -44,9 +44,14 @@ /* Path for the configuration file. */ #define _PATH_NSCDCONF "/etc/nscd.conf" -/* Maximu allowed length for the key. */ +/* Maximum allowed length for the key. */ #define MAXKEYLEN 1024 +/* Maximum alignment requirement we will encounter. */ +#define BLOCK_ALIGN_LOG 3 +#define BLOCK_ALIGN (1 << BLOCK_ALIGN_LOG) +#define BLOCK_ALIGN_M1 (BLOCK_ALIGN - 1) + /* Available services. */ typedef enum diff --git a/nscd/nscd.h b/nscd/nscd.h index 3279b85432..632bf58dc5 100644 --- a/nscd/nscd.h +++ b/nscd/nscd.h @@ -111,11 +111,6 @@ struct database_dyn /* Path used when not using persistent storage. */ #define _PATH_NSCD_XYZ_DB_TMP "/var/run/nscd/dbXXXXXX" -/* Maximum alignment requirement we will encounter. */ -#define BLOCK_ALIGN_LOG 3 -#define BLOCK_ALIGN (1 << BLOCK_ALIGN_LOG) -#define BLOCK_ALIGN_M1 (BLOCK_ALIGN - 1) - /* Default value for the maximum size of the database files. */ #define DEFAULT_MAX_DB_SIZE (32 * 1024 * 1024) diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c index db247962b9..80ee3e1dd9 100644 --- a/nscd/nscd_helper.c +++ b/nscd/nscd_helper.c @@ -481,6 +481,7 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, ref_t trail = mapped->head->array[hash]; trail = atomic_forced_read (trail); ref_t work = trail; + size_t loop_cnt = datasize / (offsetof (struct datahead, data) + datalen); int tick = 0; while (work != ENDREF && work + sizeof (struct hashentry) <= datasize) @@ -527,7 +528,7 @@ __nscd_cache_search (request_type type, const char *key, size_t keylen, work = atomic_forced_read (here->next); /* Prevent endless loops. This should never happen but perhaps the database got corrupted, accidentally or deliberately. */ - if (work == trail) + if (work == trail || loop_cnt-- > 0) break; if (tick) { |