Don't use asprintf in this library - breaks the build on many systems. Fake with...
authorJeremy Allison <jra@samba.org>
Wed, 9 Feb 2011 18:28:08 +0000 (10:28 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 9 Feb 2011 20:21:04 +0000 (21:21 +0100)
source3/libsmb/smb_share_modes.c

index 31745008204655375abe9742507d464e061409ea..e752f618a40aff5ad2bc88a8981a41252c3bd63a 100644 (file)
@@ -267,15 +267,20 @@ static uint32_t smb_name_hash(const char *sharepath, const char *filename, int *
 {
        TDB_DATA key;
        char *fullpath = NULL;
-       int ret;
+       size_t sharepath_size = strlen(sharepath);
+       size_t filename_size = strlen(filename);
        uint32_t name_hash;
 
        *err = 0;
-       ret = asprintf(&fullpath, "%s/%s", sharepath, filename);
-       if (ret == -1) {
+       fullpath = malloc(sharepath_size + filename_size + 2);
+       if (fullpath == NULL) {
                *err = 1;
                return 0;
        }
+       memcpy(fullpath, sharepath, sharepath_size);
+       fullpath[sharepath_size] = '/';
+       memcpy(&fullpath[sharepath_size + 1], filename, filename_size + 1);
+
        key.dptr = (uint8_t *)fullpath;
        key.dsize = strlen(fullpath) + 1;
        name_hash = tdb_jenkins_hash(&key);