RFC: fix a check in stat_cache_add()

Ralph Böhme slow at samba.org
Wed Jun 27 11:13:00 UTC 2018


Hi!

I just stumbled upon a check in stat_cache_add() that seems to be wrong, cf the
commit message in the attached patch. What do you think?

-slow

-- 
Ralph Boehme, Samba Team       https://samba.org/
Samba Developer, SerNet GmbH   https://sernet.de/en/samba/
GPG Key Fingerprint:           FAE2 C608 8A24 2520 51C5
                               59E4 AA1E 9B71 2639 9E46
-------------- next part --------------
From 8f9aa76cdaf04de73b25485488d96cdf4122f7e7 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Wed, 27 Jun 2018 13:07:00 +0200
Subject: [PATCH] s3: smbd: fix a check in stat_cache_add()

As the comment above the if condition says:

        /*
         * If we are in case insentive mode, we don't need to
         * store names that need no translation - else, it
         * would be a waste.
         */

Ie if stat_cache_add() is called as

        stat_cache_add("foo/bar", "foo/bar", false)

There's no need to cache the path, as a simple stat() on the client
supplied name (full_orig_name) matches the name used in the
filesystem (passed to stat_cache_add() as translated_path).

So fix the if condition to match the comment.
---
 source3/smbd/statcache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index d49f5eebdf0..27f9dec48f7 100644
--- a/source3/smbd/statcache.c
+++ b/source3/smbd/statcache.c
@@ -73,7 +73,7 @@ void stat_cache_add( const char *full_orig_name,
 	 * would be a waste.
 	 */
 
-	if (case_sensitive && (strcmp(full_orig_name, translated_path) == 0)) {
+	if (!case_sensitive && (strcmp(full_orig_name, translated_path) == 0)) {
 		return;
 	}
 
-- 
2.13.6



More information about the samba-technical mailing list