Fix bug #10010 - Missing integer wrap protection in EA list reading can cause server to loop with DOS.

Ensure we never wrap whilst adding client provided input.
CVE-2013-4124

Signed-off-by: Jeremy Allison <jra@samba.org>
WHATSNEW: Add release notes for Samba 3.6.17.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
VERSION: Bump version number up to 3.6.18.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
(cherry picked from commit dda0d8da02a41be149af5b66e6b77dae2fd6f227)
WHATSNEW: Start release notes for Samba 3.6.18.

Signed-off-by: Karolin Seeger <kseeger@samba.org>
(cherry picked from commit cb48b067251c3a523b1bdc10bf4b3ff4fc8b104f)
Change source3/modules/vfs_dirsort.c from MALLOC -> TALLOC.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit e2118fd251ac64f47a9ee4ea18a441ae1941fe4e)
Protect against early error in SMB_VFS_NEXT_READDIR.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit f34063ed9cd3d6a4542c39ad576c6ecc807878e8)
Use an index i rather than re-using a state variable.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit f81822166d8d41c6c3ee6f17924ebe87e4303211)
Protect open_and_sort_dir() from the directory changing size.

Otherwise there could be an error between initial count, allocation
and re-read.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 582d8ca565ad12133a4319650e886f58246b3bd9)
Clean error paths in opendir and fd_opendir by only setting handle data on success.

Pass extra struct dirsort_privates * to open_and_sort_dir() function
to avoid it having to re-read the handle data.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit a2da5a78c48e9be6ec2ecad99ddd23d4773b2267)
Check SMB_VFS_NEXT_OPENDIR return in dirsort_opendir().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 052f74c2122301a3be19ab84ee4551f3259a3ee5)
Convert mtime from a time_t to a struct timespec.

In preparation for removing the dirfd and using fsp_stat()
and VFS_STAT functions.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 8a761c7806fddd0faa919f343a079f8d4f343316)
Remove the use of dirfd inside the vfs_dirsort.c.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit ffc2d250d2d0fd59a1524e15c4be5cf53d5b0135)
Remove unneeded initializations (we already talloc_zero).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 8a1ec80ee233405f2f484c31a8d6e4b2702678e0)
Ensure we test the dirsort module in make test.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Apr 11 21:17:21 CEST 2013 on sn-devel-104

The last 10 patches address bug #9777 - vfs_dirsort uses non-stackable calls,
dirfd(), malloc instead of talloc and doesn't cope with directories being
modified whilst reading.
(cherry picked from commit 1f601d14d0ee440126d7202924e5cf7af88f6ea3)
winbind/idmap_ad: be verbose about the user that we fail to map

Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit f08205be7003f6c0a15fd5fd99d01951164ad15c)

Reviewed-by: David Disseldorp <ddiss@samba.org>
(cherry picked from commit 17794737fedf095212cf45920dd1e29b5a1a9fa0)
docs: mention AD prerequirements for using idmap_ad

Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit c3057f69a274f0d8e0e66183bd5e8be7703b6750)

Reviewed-by: David Disseldorp <ddiss@samba.org>

The last 2 patches address bug #9880 - Use of wrong RFC2307 primary group field.
(cherry picked from commit 006ba0cc73a3fe484452f594a25dd3bfee9b39fd)
libreplace: add a missing "eval" to the AC_VERIFY_C_PROTOTYPE macro

Without this eval, upon test success the corresponding actions
(like defining corresponding variables) are not taken.

Found by Timur I. Bakeyev, and based on his patch for 3.5.
(cherry picked from commit 0ef506d4f31d206c300e4f3f326edac2b60bdc15)
(cherry picked from commit e98d3b7648fe298f03e408ab91b8b53904bab8ca)
PIDL: fix parsing linemarkers in preprocessor output

When PIDL calls out to C preprocessor to expand IDL files
and parse the output, it filters out linemarkers and line control
information as described in http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
and http://gcc.gnu.org/onlinedocs/cpp/Line-Control.html#Line-Control

With gcc 4.8 stdc-predef.h is included automatically and linemarker for the
file has extended flags that PIDL couldn't parse ('system header that needs to
be extern "C" protected for C++')

Thanks to Jakub Jelinek <jakub@redhat.com> for explanation of the linemarker format.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=906517

Reviewed-by: Andreas Schneider <asn@samba.org>
(cherry picked from commit 6ba7ab5c14801aecae96373d5a9db7ab82957526)

Signed-off-by: Andreas Schneider <asn@samba.org>

Fix bug #9636 - pidl can't parse new linemarkers in preprocessor output.
(cherry picked from commit 643571470f2e4cd2f58bd60ac7189abb826d33cc)
(cherry picked from commit b5a8afd6550e9091d169d3010751913bb483fc4b)
build:autoconf: fix output of syslog-facility check

thanks to Thomas Bork for reporting!

Signed-off-by: Bjoern Jacke <bj@sernet.de>

Fix bug #9983 - configure and syslog facility and disk-quotas support.
(cherry picked from commit dbb52ee98b84659386d70f0e75b0fa93fada1a97)
security.idl: add new security_secinfo bits

[MS-DTYP].pdf 2.4.7

Signed-off-by: Gregor Beck <gbeck@sernet.de>
(cherry picked from commit 326ebbdaca4d13fa498779f960a202955531576b)