smb/cifs fixes for stable45

backport of #1654, #1636  and https://github.com/owncloud/3rdparty/pull/12

@karlitschek @icewind1991 THX