Bug 7759 - vfswrap_ntimes doesn't check ft pointer for NULL in proper place, got SEGFAULT when called SMB_VFS_NEXT_NTIMES(handle, smb_fname, NULL)
Summary: vfswrap_ntimes doesn't check ft pointer for NULL in proper place, got SEGFAUL...
Alias: None
Product: Samba 3.5
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: 3.5.4
Hardware: x64 Linux
: P3 normal
Target Milestone: ---
Assignee: Samba Bugzilla Account
QA Contact: Samba QA Contact
Depends on:
Reported: 2010-10-28 02:23 UTC by Volodymyr Khomenko (dead mail address)
Modified: 2010-10-28 04:23 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Volodymyr Khomenko (dead mail address) 2010-10-28 02:23:18 UTC
Samba default implementation for NTIMES VFS verb (vfswrap_ntimes, source3/modules/vfs_deatult.c) used to support easy 'update mtime/atime times to current' semantics (the same way as utime() does). Still new code (added for handling create_time?) doesn't check ft for NULL before use, so SIGSEGV happens when trying to use this feature from VFS module via SMB_VFS_NEXT_NTIMES.

P.S. vfswrap_ntimes checks ft for NULL but too late.

The fix for this issue can be done like this:
--- source3/modules/vfs_default.c
+++ source3/modules/vfs_default.c
@@ -868,6 +868,7 @@ static int vfswrap_ntimes(vfs_handle_str
        goto out;

+   if (ft != NULL) {
    if (null_timespec(ft->atime)) {
        ft->atime= smb_fname->st.st_ex_atime;
@@ -888,6 +889,7 @@ static int vfswrap_ntimes(vfs_handle_str
                &smb_fname->st.st_ex_mtime) == 0)) {
        return 0;
+   }

 #if defined(HAVE_UTIMENSAT)
    if (ft != NULL) {
Comment 1 Volker Lendecke 2010-10-28 04:23:06 UTC
Pushed to master and v3-6. If you need that in 3.5 as well (is it there? haven't looked), please let us know.