diff options
author | Jeremy Allison <jra@samba.org> | 2004-06-02 23:19:36 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:51:52 -0500 |
commit | ac5f0785c83d971a043cc99369dd491bee2be302 (patch) | |
tree | b541e7c945d69536d791ef5c6f6010e4dc5b0a3f /source3/locking | |
parent | e707189db3dbaa2874f383cf623b1c75f23c393c (diff) | |
download | samba-ac5f0785c83d971a043cc99369dd491bee2be302.tar.gz samba-ac5f0785c83d971a043cc99369dd491bee2be302.tar.bz2 samba-ac5f0785c83d971a043cc99369dd491bee2be302.zip |
r984: Ensure memmove & memcpy aren't called with len == 0.
Jeremy.
(This used to be commit 40c77dddc65e18b879d922379d562ffb8be80ab5)
Diffstat (limited to 'source3/locking')
-rw-r--r-- | source3/locking/locking.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 42036cc70c..2a27d7d4cd 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -454,8 +454,10 @@ int get_share_modes(connection_struct *conn, i++; } else { DEBUG(10,("get_share_modes: deleted %s\n", share_mode_str(i, entry_p) )); - memcpy( &shares[i], &shares[i+1], - sizeof(share_mode_entry) * (num_share_modes - i - 1)); + if (num_share_modes - i - 1 > 0) { + memcpy( &shares[i], &shares[i+1], + sizeof(share_mode_entry) * (num_share_modes - i - 1)); + } num_share_modes--; del_count++; } @@ -575,8 +577,10 @@ ssize_t del_share_entry( SMB_DEV_T dev, SMB_INO_T inode, if (ppse) *ppse = memdup(&shares[i], sizeof(*shares)); data->u.num_share_mode_entries--; - memmove(&shares[i], &shares[i+1], - dbuf.dsize - (sizeof(*data) + (i+1)*sizeof(*shares))); + if ((dbuf.dsize - (sizeof(*data) + (i+1)*sizeof(*shares))) > 0) { + memmove(&shares[i], &shares[i+1], + dbuf.dsize - (sizeof(*data) + (i+1)*sizeof(*shares))); + } del_count++; DEBUG(10,("del_share_entry: deleting entry %d\n", i )); |