s3/smbd: Fix string buffer overflow causing heap corruption
commit05b5ca0c5479a28bfe9a43cc31e813b4c25c2c2b
authorSteven Danneman <steven.danneman@isilon.com>
Sat, 30 Jan 2010 21:29:23 +0000 (30 13:29 -0800)
committerKarolin Seeger <kseeger@samba.org>
Wed, 10 Feb 2010 10:08:38 +0000 (10 11:08 +0100)
tree1f1d227e54f626a23f1380605b9ffaa0b3e6b6bf
parentb538cbeb039f0780b462a987342787a8c2c7a625
s3/smbd: Fix string buffer overflow causing heap corruption

The destname malloc size was not taking into account the 1 extra byte
needed if a string without a leading '/' was passed in and that slash
was added.

This would cause the '\0' byte to be written past the end of the
malloced destname string and corrupt whatever heap memory was there.

This problem would be hit if a share name was given in smb.conf without
a leading '/' and if it was the exact size of the allocated STRDUP memory
which in some implementations of malloc is a power of 2.
(cherry picked from commit f42971c520360e69c4cdd64bebb02a5f5ba49b94)

Fix bug #7096.
(cherry picked from commit db5ccb70b6ac51ea263889cc9cdd523673ae8ecd)
source3/smbd/service.c