summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-03-17 08:03:08 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-03-17 08:03:08 +0000
commita564fed756a82d944ebde45da1ce4ea932011f10 (patch)
tree46a79a8e76e1abc070f834be920dd6566234b237 /source3/smbd
parent1eae003fefaa8e4e9e131c9d5f2a299cec2b5e55 (diff)
downloadsamba-a564fed756a82d944ebde45da1ce4ea932011f10.tar.gz
samba-a564fed756a82d944ebde45da1ce4ea932011f10.tar.bz2
samba-a564fed756a82d944ebde45da1ce4ea932011f10.zip
More statcache fixes - and add a bit more doco.
Andrew Bartlett (This used to be commit 0e8dd52f6973ac5219e2c2dd53824de71f512083)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/statcache.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index 57ba6ada81..b1cb0f6e0f 100644
--- a/source3/smbd/statcache.c
+++ b/source3/smbd/statcache.c
@@ -39,11 +39,19 @@ typedef struct {
#define INIT_STAT_CACHE_SIZE 512
static hash_table stat_cache;
-/****************************************************************************
- Add an entry into the stat cache.
-*****************************************************************************/
+/**
+ * Add an entry into the stat cache.
+ *
+ * @param full_orig_name The original name as specified by the client
+ * @param orig_translated_path The name on our filesystem.
+ *
+ * @note Only the first strlen(orig_translated_path) characters are stored
+ * into the cache. This means that full_orig_name will be internally
+ * truncated.
+ *
+ */
-void stat_cache_add( char *full_orig_name, char *orig_translated_path)
+void stat_cache_add( const char *full_orig_name, const char *orig_translated_path)
{
stat_cache_entry *scp;
stat_cache_entry *found_scp;
@@ -105,11 +113,19 @@ void stat_cache_add( char *full_orig_name, char *orig_translated_path)
if(!case_sensitive)
strupper(original_path);
- if(!(original_path_length == translated_path_length)) {
- DEBUG(0, ("OOPS - tried to store stat cache entry for non-equal length paths [%s] %u and [%s] %u)!\n", original_path, original_path_length, translated_path, translated_path_length));
- SAFE_FREE(original_path);
- SAFE_FREE(translated_path);
- return;
+ if (original_path_length != translated_path_length) {
+ if (original_path_length < translated_path_length) {
+ DEBUG(0, ("OOPS - tried to store stat cache entry for werid length paths [%s] %u and [%s] %u)!\n", original_path, original_path_length, translated_path, translated_path_length));
+ SAFE_FREE(original_path);
+ SAFE_FREE(translated_path);
+ return;
+ }
+
+ /* we only want to store the first part of translated_path,
+ up to the length of original_path */
+
+ translated_path[original_path_length] = '\0';
+ translated_path_length = original_path_length;
}
#if 0