The branch, master has been updated
       via  13a2011 Change all uses of uint16/uint32/uint64 to uintXX_t in 
smb.h.
       via  883aa31 winbind: Avoid a few talloc_tos() in winbindd_cache.c
       via  6a19b3d winbind: Use tdb_parse_record in wcache_fetch_seqnum
      from  4491817 s3: smbd: Make sure we do not pass paths with ./ on the 
front to VFS routines.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 13a2011a05ce577e039b00147002c9e7a98355b6
Author: Richard Sharpe <rsha...@samba.org>
Date:   Tue Apr 14 07:02:37 2015 -0700

    Change all uses of uint16/uint32/uint64 to uintXX_t in smb.h.
    
    Signed-off-by: Richard Sharpe <rsha...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Thu Apr 16 23:44:00 CEST 2015 on sn-devel-104

commit 883aa314b88233bb97a33c9607865cfc612b3091
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Apr 14 10:17:20 2015 +0000

    winbind: Avoid a few talloc_tos() in winbindd_cache.c
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 6a19b3dea8655eb8fce3b16ab0cd99eded00410c
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Apr 14 10:06:55 2015 +0000

    winbind: Use tdb_parse_record in wcache_fetch_seqnum
    
    This removes a malloc use
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/include/smb.h             | 32 ++++++++---------
 source3/winbindd/winbindd_cache.c | 75 ++++++++++++++++++++-------------------
 2 files changed, 54 insertions(+), 53 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/smb.h b/source3/include/smb.h
index 9c5e1ac..7026cb4 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -191,20 +191,20 @@ struct interface {
 
 Offset  Data                   length.
 0      struct server_id pid    4
-4      uint16 op_mid           8
-12     uint16 op_type          2
-14     uint32 access_mask      4
-18     uint32 share_access     4
-22     uint32 private_options  4
-26     uint32 time sec         4
-30     uint32 time usec        4
-34     uint64 dev              8 bytes
-42     uint64 inode            8 bytes
-50     uint64 extid            8 bytes
+4      uint16_t op_mid         8
+12     uint16_t op_type        2
+14     uint32_t access_mask    4
+18     uint32_t share_access   4
+22     uint32_t private_options        4
+26     uint32_t time sec               4
+30     uint32_t time usec      4
+34     uint64_t dev            8 bytes
+42     uint64_t inode          8 bytes
+50     uint64_t extid          8 bytes
 58     unsigned long file_id   4 bytes
-62     uint32 uid              4 bytes
-66     uint16 flags            2 bytes
-68     uint32 name_hash        4 bytes
+62     uint32_t uid            4 bytes
+66     uint16_t flags          2 bytes
+68     uint32_t name_hash      4 bytes
 72
 
 */
@@ -801,9 +801,9 @@ enum file_close_type 
{NORMAL_CLOSE=0,SHUTDOWN_CLOSE,ERROR_CLOSE};
 #define SAMBA_EXTENDED_INFO_MAGIC 0x536d4261 /* "SmBa" */
 #define SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH 28
 struct smb_extended_info {
-       uint32 samba_magic;             /* Always SAMBA_EXTRA_INFO_MAGIC */
-       uint32 samba_version;           /* Major/Minor/Release/Revision */
-       uint32 samba_subversion;        /* Prerelease/RC/Vendor patch */
+       uint32_t samba_magic;           /* Always SAMBA_EXTRA_INFO_MAGIC */
+       uint32_t samba_version;         /* Major/Minor/Release/Revision */
+       uint32_t samba_subversion;      /* Prerelease/RC/Vendor patch */
        NTTIME samba_gitcommitdate;
        char   samba_version_string[SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH];
 };
diff --git a/source3/winbindd/winbindd_cache.c 
b/source3/winbindd/winbindd_cache.c
index 90270ba..def5fa0 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -398,43 +398,48 @@ static bool wcache_server_down(struct winbindd_domain 
*domain)
        return ret;
 }
 
-static bool wcache_fetch_seqnum(const char *domain_name, uint32_t *seqnum,
-                               uint32_t *last_seq_check)
+struct wcache_seqnum_state {
+       uint32_t *seqnum;
+       uint32_t *last_seq_check;
+};
+
+static int wcache_seqnum_parser(TDB_DATA key, TDB_DATA data,
+                               void *private_data)
 {
-       char *key;
-       TDB_DATA data;
+       struct wcache_seqnum_state *state = private_data;
 
-       if (wcache->tdb == NULL) {
-               DEBUG(10,("wcache_fetch_seqnum: tdb == NULL\n"));
-               return false;
+       if (data.dsize != 8) {
+               DEBUG(10, ("wcache_fetch_seqnum: invalid data size %d\n",
+                          (int)data.dsize));
+               return -1;
        }
 
-       key = talloc_asprintf(talloc_tos(), "SEQNUM/%s", domain_name);
-       if (key == NULL) {
-               DEBUG(10, ("talloc failed\n"));
-               return false;
-       }
+       *state->seqnum = IVAL(data.dptr, 0);
+       *state->last_seq_check = IVAL(data.dptr, 4);
+       return 0;
+}
 
-       data = tdb_fetch_bystring(wcache->tdb, key);
-       TALLOC_FREE(key);
+static bool wcache_fetch_seqnum(const char *domain_name, uint32_t *seqnum,
+                               uint32_t *last_seq_check)
+{
+       struct wcache_seqnum_state state = {
+               .seqnum = seqnum, .last_seq_check = last_seq_check
+       };
+       size_t len = strlen(domain_name);
+       char keystr[len+8];
+       TDB_DATA key = { .dptr = (uint8_t *)keystr, .dsize = sizeof(keystr) };
+       int ret;
 
-       if (data.dptr == NULL) {
-               DEBUG(10, ("wcache_fetch_seqnum: %s not found\n",
-                          domain_name));
-               return false;
-       }
-       if (data.dsize != 8) {
-               DEBUG(10, ("wcache_fetch_seqnum: invalid data size %d\n",
-                          (int)data.dsize));
-               SAFE_FREE(data.dptr);
+       if (wcache->tdb == NULL) {
+               DEBUG(10,("wcache_fetch_seqnum: tdb == NULL\n"));
                return false;
        }
 
-       *seqnum = IVAL(data.dptr, 0);
-       *last_seq_check = IVAL(data.dptr, 4);
-       SAFE_FREE(data.dptr);
+       snprintf(keystr, sizeof(keystr),  "SEQNUM/%s", domain_name);
 
-       return true;
+       ret = tdb_parse_record(wcache->tdb, key, wcache_seqnum_parser,
+                              &state);
+       return (ret == 0);
 }
 
 static NTSTATUS fetch_cache_seqnum( struct winbindd_domain *domain, time_t now 
)
@@ -467,7 +472,9 @@ static NTSTATUS fetch_cache_seqnum( struct winbindd_domain 
*domain, time_t now )
 bool wcache_store_seqnum(const char *domain_name, uint32_t seqnum,
                         time_t last_seq_check)
 {
-       char *key_str;
+       size_t len = strlen(domain_name);
+       char keystr[len+8];
+       TDB_DATA key = { .dptr = (uint8_t *)keystr, .dsize = sizeof(keystr) };
        uint8_t buf[8];
        int ret;
 
@@ -476,22 +483,16 @@ bool wcache_store_seqnum(const char *domain_name, 
uint32_t seqnum,
                return false;
        }
 
-       key_str = talloc_asprintf(talloc_tos(), "SEQNUM/%s", domain_name);
-       if (key_str == NULL) {
-               DEBUG(10, ("talloc_asprintf failed\n"));
-               return false;
-       }
+       snprintf(keystr, sizeof(keystr),  "SEQNUM/%s", domain_name);
 
        SIVAL(buf, 0, seqnum);
        SIVAL(buf, 4, last_seq_check);
 
-       ret = tdb_store_bystring(wcache->tdb, key_str,
-                                make_tdb_data(buf, sizeof(buf)), TDB_REPLACE);
-       TALLOC_FREE(key_str);
+       ret = tdb_store(wcache->tdb, key, make_tdb_data(buf, sizeof(buf)),
+                       TDB_REPLACE);
        if (ret != 0) {
                DEBUG(10, ("tdb_store_bystring failed: %s\n",
                           tdb_errorstr(wcache->tdb)));
-               TALLOC_FREE(key_str);
                return false;
        }
 


-- 
Samba Shared Repository

Reply via email to