diff options
author | Jeremy Allison <jra@samba.org> | 2007-03-29 22:12:28 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:19:01 -0500 |
commit | 1ff60ed7bc75991449900670bc3e6b5b91c9003d (patch) | |
tree | 273283a458477df6dfd5313dbd6388072373b5aa /source3/libsmb | |
parent | 0eefab112fc1634dc45870df7bb210b1afe59783 (diff) | |
download | samba-1ff60ed7bc75991449900670bc3e6b5b91c9003d.tar.gz samba-1ff60ed7bc75991449900670bc3e6b5b91c9003d.tar.bz2 samba-1ff60ed7bc75991449900670bc3e6b5b91c9003d.zip |
r22012: Ensure we use the same technique to pull the share mode
data out that locking/locking.c does.
Jeremy.
(This used to be commit 1fec4da6d6267289bf93f930de4cb5e21c450e15)
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/smb_share_modes.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/source3/libsmb/smb_share_modes.c b/source3/libsmb/smb_share_modes.c index e98de5e264..f78eaf8ca5 100644 --- a/source3/libsmb/smb_share_modes.c +++ b/source3/libsmb/smb_share_modes.c @@ -200,7 +200,7 @@ int smb_get_share_mode_entries(struct smbdb_ctx *db_ctx, memset(list, '\0', num_share_modes * sizeof(struct smb_share_mode_entry)); - shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry)); + shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data)); list_num = 0; for (i = 0; i < num_share_modes; i++) { @@ -265,7 +265,8 @@ int smb_create_share_mode_entry_ex(struct smbdb_ctx *db_ctx, if (!db_data.dptr) { /* We must create the entry. */ db_data.dptr = (uint8 *)malloc( - (2*sizeof(struct share_mode_entry)) + + sizeof(struct locking_data) + + sizeof(struct share_mode_entry) + strlen(sharepath) + 1 + strlen(filename) + 1); if (!db_data.dptr) { @@ -276,18 +277,18 @@ int smb_create_share_mode_entry_ex(struct smbdb_ctx *db_ctx, ld->u.s.num_share_mode_entries = 1; ld->u.s.delete_on_close = 0; ld->u.s.delete_token_size = 0; - shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry)); + shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data)); create_share_mode_entry(shares, new_entry); - memcpy(db_data.dptr + 2*sizeof(struct share_mode_entry), + memcpy(db_data.dptr + sizeof(struct locking_data) + sizeof(struct share_mode_entry), sharepath, strlen(sharepath) + 1); - memcpy(db_data.dptr + 2*sizeof(struct share_mode_entry) + + memcpy(db_data.dptr + sizeof(struct locking_data) + sizeof(struct share_mode_entry) + strlen(sharepath) + 1, filename, strlen(filename) + 1); - db_data.dsize = 2*sizeof(struct share_mode_entry) + + db_data.dsize = sizeof(struct locking_data) + sizeof(struct share_mode_entry) + strlen(sharepath) + 1 + strlen(filename) + 1; if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_INSERT) == -1) { @@ -310,11 +311,11 @@ int smb_create_share_mode_entry_ex(struct smbdb_ctx *db_ctx, orig_num_share_modes = ld->u.s.num_share_mode_entries; /* Copy the original data. */ - memcpy(new_data_p, db_data.dptr, (orig_num_share_modes+1)*sizeof(struct share_mode_entry)); + memcpy(new_data_p, db_data.dptr, sizeof(struct locking_data) + (orig_num_share_modes * sizeof(struct share_mode_entry))); /* Add in the new share mode */ - shares = (struct share_mode_entry *)(new_data_p + - ((orig_num_share_modes+1)*sizeof(struct share_mode_entry))); + shares = (struct share_mode_entry *)(new_data_p + sizeof(struct locking_data) + + (orig_num_share_modes * sizeof(struct share_mode_entry))); create_share_mode_entry(shares, new_entry); @@ -322,9 +323,9 @@ int smb_create_share_mode_entry_ex(struct smbdb_ctx *db_ctx, ld->u.s.num_share_mode_entries++; /* Append the original delete_token and filenames. */ - memcpy(new_data_p + ((ld->u.s.num_share_mode_entries+1)*sizeof(struct share_mode_entry)), - db_data.dptr + ((orig_num_share_modes+1)*sizeof(struct share_mode_entry)), - db_data.dsize - ((orig_num_share_modes+1) * sizeof(struct share_mode_entry))); + memcpy(new_data_p + sizeof(struct locking_data) + (ld->u.s.num_share_mode_entries * sizeof(struct share_mode_entry)), + db_data.dptr + sizeof(struct locking_data) + (orig_num_share_modes * sizeof(struct share_mode_entry)), + db_data.dsize - sizeof(struct locking_data) - (orig_num_share_modes * sizeof(struct share_mode_entry))); new_data_size = db_data.dsize + sizeof(struct share_mode_entry); @@ -382,7 +383,7 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx, ld = (struct locking_data *)db_data.dptr; orig_num_share_modes = ld->u.s.num_share_mode_entries; - shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry)); + shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data)); if (orig_num_share_modes == 1) { /* Only one entry - better be ours... */ @@ -405,7 +406,7 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx, } /* Copy the header. */ - memcpy(new_data_p, db_data.dptr, sizeof(struct share_mode_entry)); + memcpy(new_data_p, db_data.dptr, sizeof(struct locking_data)); num_share_modes = 0; for (i = 0; i < orig_num_share_modes; i++) { @@ -421,7 +422,8 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx, continue; /* This is our delete taget. */ } - memcpy(new_data_p + ((num_share_modes+1)*sizeof(struct share_mode_entry)), + memcpy(new_data_p + sizeof(struct locking_data) + + (num_share_modes * sizeof(struct share_mode_entry)), share, sizeof(struct share_mode_entry) ); num_share_modes++; @@ -435,10 +437,10 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx, } /* Copy any delete token plus the terminating filenames. */ - remaining_ptr = db_data.dptr + ((orig_num_share_modes+1) * sizeof(struct share_mode_entry)); + remaining_ptr = db_data.dptr + sizeof(struct locking_data) + (orig_num_share_modes * sizeof(struct share_mode_entry)); remaining_size = db_data.dsize - (remaining_ptr - db_data.dptr); - memcpy(new_data_p + ((num_share_modes+1)*sizeof(struct share_mode_entry)), + memcpy(new_data_p + sizeof(struct locking_data) + (num_share_modes * sizeof(struct share_mode_entry)), remaining_ptr, remaining_size); @@ -450,7 +452,7 @@ int smb_delete_share_mode_entry(struct smbdb_ctx *db_ctx, ld = (struct locking_data *)db_data.dptr; ld->u.s.num_share_mode_entries = num_share_modes; - db_data.dsize = ((num_share_modes+1)*sizeof(struct share_mode_entry)) + remaining_size; + db_data.dsize = sizeof(struct locking_data) + (num_share_modes * sizeof(struct share_mode_entry)) + remaining_size; if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) == -1) { free(db_data.dptr); @@ -481,7 +483,7 @@ int smb_change_share_mode_entry(struct smbdb_ctx *db_ctx, ld = (struct locking_data *)db_data.dptr; num_share_modes = ld->u.s.num_share_mode_entries; - shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct share_mode_entry)); + shares = (struct share_mode_entry *)(db_data.dptr + sizeof(struct locking_data)); for (i = 0; i < num_share_modes; i++) { struct share_mode_entry *share = &shares[i]; |