smbd: Simplify check_access()
[kai/samba-autobuild/.git] / source3 / smbd / trans2.c
index b950820671b5f416ab984fe6530533b72383d2c9..11c97e89269d11c847240daeeec831acb773a24b 100644 (file)
@@ -40,6 +40,7 @@
 #include "rpc_server/srv_pipe_hnd.h"
 #include "printing.h"
 #include "lib/util_ea.h"
+#include "lib/readdir_attr.h"
 
 #define DIR_ENTRY_SAFETY_MARGIN 4096
 
@@ -53,6 +54,15 @@ static char *store_file_unix_basic_info2(connection_struct *conn,
                                files_struct *fsp,
                                const SMB_STRUCT_STAT *psbuf);
 
+NTSTATUS check_access_fsp(const struct files_struct *fsp,
+                         uint32_t access_mask)
+{
+       if (!(fsp->access_mask & access_mask)) {
+               return NT_STATUS_ACCESS_DENIED;
+       }
+       return NT_STATUS_OK;
+}
+
 /********************************************************************
  The canonical "check access" based on object handle or path function.
 ********************************************************************/
@@ -62,20 +72,16 @@ NTSTATUS check_access(connection_struct *conn,
                                const struct smb_filename *smb_fname,
                                uint32_t access_mask)
 {
+       NTSTATUS status;
+
        if (fsp) {
-               if (!(fsp->access_mask & access_mask)) {
-                       return NT_STATUS_ACCESS_DENIED;
-               }
+               status = check_access_fsp(fsp, access_mask);
        } else {
-               NTSTATUS status = smbd_check_access_rights(conn,
-                                       smb_fname,
-                                       false,
-                                       access_mask);
-               if (!NT_STATUS_IS_OK(status)) {
-                       return status;
-               }
+               status = smbd_check_access_rights(conn, smb_fname,
+                                                 false, access_mask);
        }
-       return NT_STATUS_OK;
+
+       return status;
 }
 
 /********************************************************************
@@ -179,7 +185,7 @@ NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, connection_struct *conn,
        }
 
        DEBUG(10,("get_ea_value: EA %s is of length %u\n", ea_name, (unsigned int)sizeret));
-       dump_data(10, (uint8 *)val, sizeret);
+       dump_data(10, (uint8_t *)val, sizeret);
 
        pea->flags = 0;
        if (strnequal(ea_name, "user.", 5)) {
@@ -860,7 +866,6 @@ void send_trans2_replies(connection_struct *conn,
        int data_alignment_offset = 0;
        bool overflow = False;
        struct smbXsrv_connection *xconn = req->xconn;
-       struct smbd_server_connection *sconn = xconn->sconn;
        int max_send = xconn->smb1.sessions.max_send;
 
        /* Modify the data_to_send and datasize and set the error if
@@ -888,7 +893,7 @@ void send_trans2_replies(connection_struct *conn,
                                        __LINE__,__FILE__);
                }
                show_msg((char *)req->outbuf);
-               if (!srv_send_smb(sconn,
+               if (!srv_send_smb(xconn,
                                (char *)req->outbuf,
                                true, req->seqnum+1,
                                IS_CONN_ENCRYPTED(conn),
@@ -1028,7 +1033,7 @@ void send_trans2_replies(connection_struct *conn,
 
                /* Send the packet */
                show_msg((char *)req->outbuf);
-               if (!srv_send_smb(sconn,
+               if (!srv_send_smb(xconn,
                                (char *)req->outbuf,
                                true, req->seqnum+1,
                                IS_CONN_ENCRYPTED(conn),
@@ -1068,7 +1073,7 @@ static void call_trans2open(connection_struct *conn,
        char *params = *pparams;
        char *pdata = *ppdata;
        int deny_mode;
-       int32 open_attr;
+       int32_t open_attr;
        bool oplock_request;
 #if 0
        bool return_additional_info;
@@ -1076,7 +1081,7 @@ static void call_trans2open(connection_struct *conn,
        time_t open_time;
 #endif
        int open_ofun;
-       uint32 open_size;
+       uint32_t open_size;
        char *pname;
        char *fname = NULL;
        off_t size=0;
@@ -1085,12 +1090,12 @@ static void call_trans2open(connection_struct *conn,
        int smb_action = 0;
        files_struct *fsp;
        struct ea_list *ea_list = NULL;
-       uint16 flags = 0;
+       uint16_t flags = 0;
        NTSTATUS status;
-       uint32 access_mask;
-       uint32 share_mode;
-       uint32 create_disposition;
-       uint32 create_options = 0;
+       uint32_t access_mask;
+       uint32_t share_mode;
+       uint32_t create_disposition;
+       uint32_t create_options = 0;
        uint32_t private_flags = 0;
        TALLOC_CTX *ctx = talloc_tos();
 
@@ -1228,10 +1233,11 @@ static void call_trans2open(connection_struct *conn,
                NULL,                                   /* sd */
                ea_list,                                /* ea_list */
                &fsp,                                   /* result */
-               &smb_action);                           /* psbuf */
+               &smb_action,                            /* psbuf */
+               NULL, NULL);                            /* create context */
 
        if (!NT_STATUS_IS_OK(status)) {
-               if (open_was_deferred(req->sconn, req->mid)) {
+               if (open_was_deferred(req->xconn, req->mid)) {
                        /* We have re-scheduled this call. */
                        goto out;
                }
@@ -1260,7 +1266,7 @@ static void call_trans2open(connection_struct *conn,
        SSVAL(params,0,fsp->fnum);
        SSVAL(params,2,fattr);
        srv_put_dos_date2(params,4, mtime);
-       SIVAL(params,8, (uint32)size);
+       SIVAL(params,8, (uint32_t)size);
        SSVAL(params,12,deny_mode);
        SSVAL(params,14,0); /* open_type - file or directory. */
        SSVAL(params,16,0); /* open_state - only valid for IPC device. */
@@ -1277,7 +1283,7 @@ static void call_trans2open(connection_struct *conn,
        SIVAL(params,20,inode);
        SSVAL(params,24,0); /* Padding. */
        if (flags & 8) {
-               uint32 ea_size = estimate_ea_size(conn, fsp,
+               uint32_t ea_size = estimate_ea_size(conn, fsp,
                                                  smb_fname);
                SIVAL(params, 26, ea_size);
        } else {
@@ -1321,7 +1327,7 @@ static bool exact_match(bool has_wild,
  Return the filetype for UNIX extensions.
 ****************************************************************************/
 
-static uint32 unix_filetype(mode_t mode)
+static uint32_t unix_filetype(mode_t mode)
 {
        if(S_ISREG(mode))
                return UNIX_TYPE_FILE;
@@ -1360,7 +1366,7 @@ enum perm_type { PERM_NEW_FILE, PERM_NEW_DIR, PERM_EXISTING_FILE, PERM_EXISTING_
 
 static NTSTATUS unix_perms_from_wire( connection_struct *conn,
                                const SMB_STRUCT_STAT *psbuf,
-                               uint32 perms,
+                               uint32_t perms,
                                enum perm_type ptype,
                                mode_t *ret_perms)
 {
@@ -1469,6 +1475,31 @@ static bool smbd_dirptr_lanman2_match_fn(TALLOC_CTX *ctx,
 
        /* Mangle fname if it's an illegal name. */
        if (mangle_must_mangle(dname, state->conn->params)) {
+               /*
+                * Slow path - ensure we can push the original name as UCS2. If
+                * not, then just don't return this name.
+                */
+               NTSTATUS status;
+               size_t ret_len = 0;
+               size_t len = (strlen(dname) + 2) * 4; /* Allow enough space. */
+               uint8_t *tmp = talloc_array(talloc_tos(),
+                                       uint8_t,
+                                       len);
+
+               status = srvstr_push(NULL,
+                       FLAGS2_UNICODE_STRINGS,
+                       tmp,
+                       dname,
+                       len,
+                       STR_TERMINATE,
+                       &ret_len);
+
+               TALLOC_FREE(tmp);
+
+               if (!NT_STATUS_IS_OK(status)) {
+                       return false;
+               }
+
                ok = name_to_8_3(dname, mangled_name,
                                 true, state->conn->params);
                if (!ok) {
@@ -1594,7 +1625,10 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
        uint64_t allocation_size = 0;
        uint64_t file_index = 0;
        size_t len = 0;
-       struct timespec mdate_ts, adate_ts, cdate_ts, create_date_ts;
+       struct timespec mdate_ts = {0};
+       struct timespec adate_ts = {0};
+       struct timespec cdate_ts = {0};
+       struct timespec create_date_ts = {0};
        time_t mdate = (time_t)0, adate = (time_t)0, create_date = (time_t)0;
        char *nameptr;
        char *last_entry_ptr;
@@ -1602,17 +1636,20 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
        int off;
        int pad = 0;
        NTSTATUS status;
-
-       ZERO_STRUCT(mdate_ts);
-       ZERO_STRUCT(adate_ts);
-       ZERO_STRUCT(create_date_ts);
-       ZERO_STRUCT(cdate_ts);
+       struct readdir_attr_data *readdir_attr_data = NULL;
 
        if (!(mode & FILE_ATTRIBUTE_DIRECTORY)) {
                file_size = get_file_size_stat(&smb_fname->st);
        }
        allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn, NULL, &smb_fname->st);
 
+       status = SMB_VFS_READDIR_ATTR(conn, smb_fname, ctx, &readdir_attr_data);
+       if (!NT_STATUS_IS_OK(status)) {
+               if (!NT_STATUS_EQUAL(NT_STATUS_NOT_SUPPORTED, status)) {
+                       return status;
+               }
+       }
+
        file_index = get_FileIndex(conn, &smb_fname->st);
 
        mdate_ts = smb_fname->st.st_ex_mtime;
@@ -1673,8 +1710,8 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
                srv_put_dos_date2(p,0,create_date);
                srv_put_dos_date2(p,4,adate);
                srv_put_dos_date2(p,8,mdate);
-               SIVAL(p,12,(uint32)file_size);
-               SIVAL(p,16,(uint32)allocation_size);
+               SIVAL(p,12,(uint32_t)file_size);
+               SIVAL(p,16,(uint32_t)allocation_size);
                SSVAL(p,20,mode);
                p += 23;
                nameptr = p;
@@ -1712,8 +1749,8 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
                srv_put_dos_date2(p,0,create_date);
                srv_put_dos_date2(p,4,adate);
                srv_put_dos_date2(p,8,mdate);
-               SIVAL(p,12,(uint32)file_size);
-               SIVAL(p,16,(uint32)allocation_size);
+               SIVAL(p,12,(uint32_t)file_size);
+               SIVAL(p,16,(uint32_t)allocation_size);
                SSVAL(p,20,mode);
                {
                        unsigned int ea_size = estimate_ea_size(conn, NULL,
@@ -1762,8 +1799,8 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
                srv_put_dos_date2(p,0,create_date);
                srv_put_dos_date2(p,4,adate);
                srv_put_dos_date2(p,8,mdate);
-               SIVAL(p,12,(uint32)file_size);
-               SIVAL(p,16,(uint32)allocation_size);
+               SIVAL(p,12,(uint32_t)file_size);
+               SIVAL(p,16,(uint32_t)allocation_size);
                SSVAL(p,20,mode);
                p += 22; /* p now points to the EA area. */
 
@@ -2073,17 +2110,41 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
                q = p; p += 4; /* q is placeholder for name length */
                if (mode & FILE_ATTRIBUTE_REPARSE_POINT) {
                        SIVAL(p, 0, IO_REPARSE_TAG_DFS);
+               } else if (readdir_attr_data &&
+                          readdir_attr_data->type == RDATTR_AAPL) {
+                       /*
+                        * OS X specific SMB2 extension negotiated via
+                        * AAPL create context: return max_access in
+                        * ea_size field.
+                        */
+                       SIVAL(p, 0, readdir_attr_data->attr_data.aapl.max_access);
                } else {
                        unsigned int ea_size = estimate_ea_size(conn, NULL,
                                                                smb_fname);
                        SIVAL(p,0,ea_size); /* Extended attributes */
                }
                p += 4;
-               /* Clear the short name buffer. This is
-                * IMPORTANT as not doing so will trigger
-                * a Win2k client bug. JRA.
-                */
-               if (!was_8_3 && check_mangled_names) {
+
+               if (readdir_attr_data &&
+                   readdir_attr_data->type == RDATTR_AAPL) {
+                       /*
+                        * OS X specific SMB2 extension negotiated via
+                        * AAPL create context: return resource fork
+                        * length and compressed FinderInfo in
+                        * shortname field.
+                        *
+                        * According to documentation short_name_len
+                        * should be 0, but on the wire behaviour
+                        * shows its set to 24 by clients.
+                        */
+                       SSVAL(p, 0, 24);
+
+                       /* Resourefork length */
+                       SBVAL(p, 2, readdir_attr_data->attr_data.aapl.rfork_size);
+
+                       /* Compressed FinderInfo */
+                       memcpy(p + 10, &readdir_attr_data->attr_data.aapl.finder_info, 16);
+               } else if (!was_8_3 && check_mangled_names) {
                        char mangled_name[13]; /* mangled 8.3 name. */
                        if (!name_to_8_3(fname,mangled_name,True,
                                        conn->params)) {
@@ -2103,10 +2164,29 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
                        }
                        SSVAL(p, 0, len);
                } else {
+                       /* Clear the short name buffer. This is
+                        * IMPORTANT as not doing so will trigger
+                        * a Win2k client bug. JRA.
+                        */
                        memset(p,'\0',26);
                }
                p += 26;
-               SSVAL(p,0,0); p += 2; /* Reserved ? */
+
+               /* Reserved ? */
+               if (readdir_attr_data &&
+                   readdir_attr_data->type == RDATTR_AAPL) {
+                       /*
+                        * OS X specific SMB2 extension negotiated via
+                        * AAPL create context: return UNIX mode in
+                        * reserved field.
+                        */
+                       uint16_t aapl_mode = (uint16_t)readdir_attr_data->attr_data.aapl.unix_mode;
+                       SSVAL(p, 0, aapl_mode);
+               } else {
+                       SSVAL(p, 0, 0);
+               }
+               p += 2;
+
                SBVAL(p,0,file_index); p += 8;
                status = srvstr_push(base_data, flags2, p,
                                  fname, PTR_DIFF(end_data, p),
@@ -2212,12 +2292,12 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
        return NT_STATUS_OK;
 }
 
-bool smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
+NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                               connection_struct *conn,
                               struct dptr_struct *dirptr,
-                              uint16 flags2,
+                              uint16_t flags2,
                               const char *path_mask,
-                              uint32 dirtype,
+                              uint32_t dirtype,
                               int info_level,
                               int requires_resume_key,
                               bool dont_descend,
@@ -2228,7 +2308,6 @@ bool smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                               char *base_data,
                               char *end_data,
                               int space_remaining,
-                              bool *out_of_space,
                               bool *got_exact_match,
                               int *_last_entry_off,
                               struct ea_list *name_list)
@@ -2251,7 +2330,6 @@ bool smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
        state.has_wild = dptr_has_wild(dirptr);
        state.got_exact_match = false;
 
-       *out_of_space = false;
        *got_exact_match = false;
 
        p = strrchr_m(path_mask,'/');
@@ -2279,7 +2357,7 @@ bool smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                                   &mode,
                                   &prev_dirpos);
        if (!ok) {
-               return false;
+               return NT_STATUS_END_OF_FILE;
        }
 
        *got_exact_match = state.got_exact_match;
@@ -2301,27 +2379,30 @@ bool smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                                     ppdata,
                                     end_data,
                                     &last_entry_off);
+       if (NT_STATUS_EQUAL(status, NT_STATUS_ILLEGAL_CHARACTER)) {
+               DEBUG(1,("Conversion error: illegal character: %s\n",
+                        smb_fname_str_dbg(smb_fname)));
+       }
        TALLOC_FREE(fname);
        TALLOC_FREE(smb_fname);
        if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
-               *out_of_space = true;
                dptr_SeekDir(dirptr, prev_dirpos);
-               return false;
+               return status;
        }
        if (!NT_STATUS_IS_OK(status)) {
-               return false;
+               return status;
        }
 
        *_last_entry_off = last_entry_off;
-       return true;
+       return NT_STATUS_OK;
 }
 
-static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
+static NTSTATUS get_lanman2_dir_entry(TALLOC_CTX *ctx,
                                connection_struct *conn,
                                struct dptr_struct *dirptr,
-                               uint16 flags2,
+                               uint16_t flags2,
                                const char *path_mask,
-                               uint32 dirtype,
+                               uint32_t dirtype,
                                int info_level,
                                bool requires_resume_key,
                                bool dont_descend,
@@ -2330,7 +2411,6 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
                                char *base_data,
                                char *end_data,
                                int space_remaining,
-                               bool *out_of_space,
                                bool *got_exact_match,
                                int *last_entry_off,
                                struct ea_list *name_list)
@@ -2349,7 +2429,7 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
                                         align, do_pad,
                                         ppdata, base_data, end_data,
                                         space_remaining,
-                                        out_of_space, got_exact_match,
+                                        got_exact_match,
                                         last_entry_off, name_list);
 }
 
@@ -2372,9 +2452,9 @@ static void call_trans2findfirst(connection_struct *conn,
        char *params = *pparams;
        char *pdata = *ppdata;
        char *data_end;
-       uint32 dirtype;
+       uint32_t dirtype;
        int maxentries;
-       uint16 findfirst_flags;
+       uint16_t findfirst_flags;
        bool close_after_first;
        bool close_if_end;
        bool requires_resume_key;
@@ -2399,6 +2479,7 @@ static void call_trans2findfirst(connection_struct *conn,
        struct smbd_server_connection *sconn = req->sconn;
        uint32_t ucf_flags = (UCF_SAVE_LCOMP | UCF_ALWAYS_ALLOW_WCARD_LCOMP);
        bool backup_priv = false;
+       bool as_root = false;
 
        if (total_params < 13) {
                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -2464,6 +2545,7 @@ close_if_end = %d requires_resume_key = %d backup_priv = %d level = 0x%x, max_da
 
        if (backup_priv) {
                become_root();
+               as_root = true;
                ntstatus = filename_convert_with_privilege(ctx,
                                conn,
                                req,
@@ -2521,7 +2603,7 @@ close_if_end = %d requires_resume_key = %d backup_priv = %d level = 0x%x, max_da
        DEBUG(5,("dir=%s, mask = %s\n",directory, mask));
 
        if (info_level == SMB_FIND_EA_LIST) {
-               uint32 ea_size;
+               uint32_t ea_size;
 
                if (total_data < 4) {
                        reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -2562,7 +2644,11 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
        }
        pdata = *ppdata;
        data_end = pdata + max_data_bytes + DIR_ENTRY_SAFETY_MARGIN - 1;
-
+       /*
+        * squash valgrind "writev(vector[...]) points to uninitialised byte(s)"
+        * error.
+        */
+       memset(pdata + total_data, 0, ((max_data_bytes + DIR_ENTRY_SAFETY_MARGIN) - total_data));
        /* Realloc the params space */
        *pparams = (char *)SMB_REALLOC(*pparams, 10);
        if (*pparams == NULL) {
@@ -2624,7 +2710,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                        out_of_space = True;
                        finished = False;
                } else {
-                       finished = !get_lanman2_dir_entry(ctx,
+                       ntstatus = get_lanman2_dir_entry(ctx,
                                        conn,
                                        dirptr,
                                        req->flags2,
@@ -2632,14 +2718,24 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                                        requires_resume_key,dont_descend,
                                        ask_sharemode,
                                        &p,pdata,data_end,
-                                       space_remaining, &out_of_space,
+                                       space_remaining,
                                        &got_exact_match,
                                        &last_entry_off, ea_list);
+                       if (NT_STATUS_EQUAL(ntstatus,
+                                       NT_STATUS_ILLEGAL_CHARACTER)) {
+                               /*
+                                * Bad character conversion on name. Ignore this
+                                * entry.
+                                */
+                               continue;
+                       }
+                       if (NT_STATUS_EQUAL(ntstatus, STATUS_MORE_ENTRIES)) {
+                               out_of_space = true;
+                       } else {
+                               finished = !NT_STATUS_IS_OK(ntstatus);
+                       }
                }
 
-               if (finished && out_of_space)
-                       finished = False;
-
                if (!finished && !out_of_space)
                        numentries++;
 
@@ -2724,7 +2820,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
        }
  out:
 
-       if (backup_priv) {
+       if (as_root) {
                unbecome_root();
        }
 
@@ -2752,9 +2848,9 @@ static void call_trans2findnext(connection_struct *conn,
        char *data_end;
        int dptr_num;
        int maxentries;
-       uint16 info_level;
-       uint32 resume_key;
-       uint16 findnext_flags;
+       uint16_t info_level;
+       uint32_t resume_key;
+       uint16_t findnext_flags;
        bool close_after_request;
        bool close_if_end;
        bool requires_resume_key;
@@ -2764,7 +2860,7 @@ static void call_trans2findnext(connection_struct *conn,
        const char *mask = NULL;
        const char *directory = NULL;
        char *p = NULL;
-       uint16 dirtype;
+       uint16_t dirtype;
        int numentries = 0;
        int i, last_entry_off=0;
        bool finished = False;
@@ -2778,6 +2874,7 @@ static void call_trans2findnext(connection_struct *conn,
        struct dptr_struct *dirptr;
        struct smbd_server_connection *sconn = req->sconn;
        bool backup_priv = false; 
+       bool as_root = false;
 
        if (total_params < 13) {
                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -2855,7 +2952,7 @@ resume_key = %d resume name = %s continue=%d level = %d\n",
        }
 
        if (info_level == SMB_FIND_EA_LIST) {
-               uint32 ea_size;
+               uint32_t ea_size;
 
                if (total_data < 4) {
                        reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -2898,6 +2995,11 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
        pdata = *ppdata;
        data_end = pdata + max_data_bytes + DIR_ENTRY_SAFETY_MARGIN - 1;
 
+       /*
+        * squash valgrind "writev(vector[...]) points to uninitialised byte(s)"
+        * error.
+        */
+       memset(pdata + total_data, 0, (max_data_bytes + DIR_ENTRY_SAFETY_MARGIN) - total_data);
        /* Realloc the params space */
        *pparams = (char *)SMB_REALLOC(*pparams, 6*SIZEOFWORD);
        if(*pparams == NULL ) {
@@ -2951,6 +3053,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
 
        if (backup_priv) {
                become_root();
+               as_root = true;
        }
 
        /*
@@ -3000,7 +3103,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                        out_of_space = True;
                        finished = False;
                } else {
-                       finished = !get_lanman2_dir_entry(ctx,
+                       ntstatus = get_lanman2_dir_entry(ctx,
                                                conn,
                                                dirptr,
                                                req->flags2,
@@ -3008,14 +3111,24 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                                                requires_resume_key,dont_descend,
                                                ask_sharemode,
                                                &p,pdata,data_end,
-                                               space_remaining, &out_of_space,
+                                               space_remaining,
                                                &got_exact_match,
                                                &last_entry_off, ea_list);
+                       if (NT_STATUS_EQUAL(ntstatus,
+                                       NT_STATUS_ILLEGAL_CHARACTER)) {
+                               /*
+                                * Bad character conversion on name. Ignore this
+                                * entry.
+                                */
+                               continue;
+                       }
+                       if (NT_STATUS_EQUAL(ntstatus, STATUS_MORE_ENTRIES)) {
+                               out_of_space = true;
+                       } else {
+                               finished = !NT_STATUS_IS_OK(ntstatus);
+                       }
                }
 
-               if (finished && out_of_space)
-                       finished = False;
-
                if (!finished && !out_of_space)
                        numentries++;
 
@@ -3042,7 +3155,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                dptr_close(sconn, &dptr_num); /* This frees up the saved mask */
        }
 
-       if (backup_priv) {
+       if (as_root) {
                unbecome_root();
        }
 
@@ -3117,10 +3230,12 @@ NTSTATUS smbd_do_qfsinfo(struct smbXsrv_connection *xconn,
        int snum = SNUM(conn);
        const char *fstype = lp_fstype(SNUM(conn));
        const char *filename = NULL;
-       uint32 additional_flags = 0;
+       const uint64_t bytes_per_sector = 512;
+       uint32_t additional_flags = 0;
        struct smb_filename smb_fname;
        SMB_STRUCT_STAT st;
        NTSTATUS status = NT_STATUS_OK;
+       uint64_t df_ret;
 
        if (fname == NULL || fname->base_name == NULL) {
                filename = ".";
@@ -3168,9 +3283,11 @@ NTSTATUS smbd_do_qfsinfo(struct smbXsrv_connection *xconn,
        switch (info_level) {
                case SMB_INFO_ALLOCATION:
                {
-                       uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
+                       uint64_t dfree,dsize,bsize,block_size,sectors_per_unit;
                        data_len = 18;
-                       if (get_dfree_info(conn,filename,False,&bsize,&dfree,&dsize) == (uint64_t)-1) {
+                       df_ret = get_dfree_info(conn, filename, &bsize, &dfree,
+                                               &dsize);
+                       if (df_ret == (uint64_t)-1) {
                                return map_nt_error_from_unix(errno);
                        }
 
@@ -3187,7 +3304,6 @@ NTSTATUS smbd_do_qfsinfo(struct smbXsrv_connection *xconn,
                                dsize *= factor;
                                dfree *= factor;
                        }
-                       bytes_per_sector = 512;
                        sectors_per_unit = bsize/bytes_per_sector;
 
                        DEBUG(5,("smbd_do_qfsinfo : SMB_INFO_ALLOCATION id=%x, bsize=%u, cSectorUnit=%u, \
@@ -3318,9 +3434,11 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (u
                case SMB_QUERY_FS_SIZE_INFO:
                case SMB_FS_SIZE_INFORMATION:
                {
-                       uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
+                       uint64_t dfree,dsize,bsize,block_size,sectors_per_unit;
                        data_len = 24;
-                       if (get_dfree_info(conn,filename,False,&bsize,&dfree,&dsize) == (uint64_t)-1) {
+                       df_ret = get_dfree_info(conn, filename, &bsize, &dfree,
+                                               &dsize);
+                       if (df_ret == (uint64_t)-1) {
                                return map_nt_error_from_unix(errno);
                        }
                        block_size = lp_block_size(snum);
@@ -3336,7 +3454,6 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (u
                                dsize *= factor;
                                dfree *= factor;
                        }
-                       bytes_per_sector = 512;
                        sectors_per_unit = bsize/bytes_per_sector;
                        DEBUG(5,("smbd_do_qfsinfo : SMB_QUERY_FS_SIZE_INFO bsize=%u, cSectorUnit=%u, \
 cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned int)sectors_per_unit,
@@ -3351,9 +3468,11 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
 
                case SMB_FS_FULL_SIZE_INFORMATION:
                {
-                       uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
+                       uint64_t dfree,dsize,bsize,block_size,sectors_per_unit;
                        data_len = 32;
-                       if (get_dfree_info(conn,filename,False,&bsize,&dfree,&dsize) == (uint64_t)-1) {
+                       df_ret = get_dfree_info(conn, filename, &bsize, &dfree,
+                                               &dsize);
+                       if (df_ret == (uint64_t)-1) {
                                return map_nt_error_from_unix(errno);
                        }
                        block_size = lp_block_size(snum);
@@ -3369,7 +3488,6 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                                dsize *= factor;
                                dfree *= factor;
                        }
-                       bytes_per_sector = 512;
                        sectors_per_unit = bsize/bytes_per_sector;
                        DEBUG(5,("smbd_do_qfsinfo : SMB_QUERY_FS_FULL_SIZE_INFO bsize=%u, cSectorUnit=%u, \
 cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned int)sectors_per_unit,
@@ -3487,6 +3605,34 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                        break;
                }
 
+               case SMB_FS_SECTOR_SIZE_INFORMATION:
+               {
+                       data_len = 28;
+                       /*
+                        * These values match a physical Windows Server 2012
+                        * share backed by NTFS atop spinning rust.
+                        */
+                       DEBUG(5, ("SMB_FS_SECTOR_SIZE_INFORMATION:"));
+                       /* logical_bytes_per_sector */
+                       SIVAL(pdata, 0, bytes_per_sector);
+                       /* phys_bytes_per_sector_atomic */
+                       SIVAL(pdata, 4, bytes_per_sector);
+                       /* phys_bytes_per_sector_perf */
+                       SIVAL(pdata, 8, bytes_per_sector);
+                       /* fs_effective_phys_bytes_per_sector_atomic */
+                       SIVAL(pdata, 12, bytes_per_sector);
+                       /* flags */
+                       SIVAL(pdata, 16, SSINFO_FLAGS_ALIGNED_DEVICE
+                               | SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE);
+                       /* byte_off_sector_align */
+                       SIVAL(pdata, 20, 0);
+                       /* byte_off_partition_align */
+                       SIVAL(pdata, 24, 0);
+                       *fixed_portion = 28;
+                       break;
+               }
+
+
                /*
                 * Query the version and capabilities of the CIFS UNIX extensions
                 * in use.
@@ -3507,6 +3653,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                        case SMB_SIGNING_OFF:
                                encrypt_caps = 0;
                                break;
+                       case SMB_SIGNING_DESIRED:
                        case SMB_SIGNING_IF_REQUIRED:
                        case SMB_SIGNING_DEFAULT:
                                encrypt_caps = CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP;
@@ -3663,7 +3810,8 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                                        &conn->session_info->security_token->sids[i],
                                        0);
 
-                               sid_linearize(pdata + data_len, sid_len,
+                               sid_linearize((uint8_t *)(pdata + data_len),
+                                             sid_len,
                                    &conn->session_info->security_token->sids[i]);
                                data_len += sid_len;
                        }
@@ -3759,7 +3907,7 @@ static void call_trans2setfsinfo(connection_struct *conn,
        struct smbXsrv_connection *xconn = req->xconn;
        char *pdata = *ppdata;
        char *params = *pparams;
-       uint16 info_level;
+       uint16_t info_level;
 
        DEBUG(10,("call_trans2setfsinfo: for service [%s]\n",
                  lp_servicename(talloc_tos(), SNUM(conn))));
@@ -3931,7 +4079,7 @@ static void call_trans2setfsinfo(connection_struct *conn,
                                        return;
                                }
 
-                               /* note: normaly there're 48 bytes,
+                               /* note: normally there're 48 bytes,
                                 * but we didn't use the last 6 bytes for now 
                                 * --metze 
                                 */
@@ -4210,7 +4358,7 @@ static const struct {unsigned stat_fflag; unsigned smb_fflag;}
 };
 
 static void map_info2_flags_from_sbuf(const SMB_STRUCT_STAT *psbuf,
-                               uint32 *smb_fflags, uint32 *smb_fmask)
+                               uint32_t *smb_fflags, uint32_t *smb_fmask)
 {
        int i;
 
@@ -4223,11 +4371,11 @@ static void map_info2_flags_from_sbuf(const SMB_STRUCT_STAT *psbuf,
 }
 
 static bool map_info2_flags_to_sbuf(const SMB_STRUCT_STAT *psbuf,
-                               const uint32 smb_fflags,
-                               const uint32 smb_fmask,
+                               const uint32_t smb_fflags,
+                               const uint32_t smb_fmask,
                                int *stat_fflags)
 {
-       uint32 max_fmask = 0;
+       uint32_t max_fmask = 0;
        int i;
 
        *stat_fflags = psbuf->st_ex_flags;
@@ -4267,8 +4415,8 @@ static char *store_file_unix_basic_info2(connection_struct *conn,
                                files_struct *fsp,
                                const SMB_STRUCT_STAT *psbuf)
 {
-       uint32 file_flags = 0;
-       uint32 flags_mask = 0;
+       uint32_t file_flags = 0;
+       uint32_t flags_mask = 0;
 
        pdata = store_file_unix_basic(conn, pdata, fsp, psbuf);
 
@@ -4380,7 +4528,7 @@ static void call_trans2qpipeinfo(connection_struct *conn,
        char *pdata = *ppdata;
        unsigned int data_size = 0;
        unsigned int param_size = 2;
-       uint16 info_level;
+       uint16_t info_level;
        files_struct *fsp;
 
        if (!params) {
@@ -4603,8 +4751,8 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        srv_put_dos_date2(pdata,l1_fdateCreation,create_time);
                        srv_put_dos_date2(pdata,l1_fdateLastAccess,atime);
                        srv_put_dos_date2(pdata,l1_fdateLastWrite,mtime); /* write time */
-                       SIVAL(pdata,l1_cbFile,(uint32)file_size);
-                       SIVAL(pdata,l1_cbFileAlloc,(uint32)allocation_size);
+                       SIVAL(pdata,l1_cbFile,(uint32_t)file_size);
+                       SIVAL(pdata,l1_cbFileAlloc,(uint32_t)allocation_size);
                        SSVAL(pdata,l1_attrFile,mode);
                        break;
 
@@ -4618,8 +4766,8 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        srv_put_dos_date2(pdata,0,create_time);
                        srv_put_dos_date2(pdata,4,atime);
                        srv_put_dos_date2(pdata,8,mtime); /* write time */
-                       SIVAL(pdata,12,(uint32)file_size);
-                       SIVAL(pdata,16,(uint32)allocation_size);
+                       SIVAL(pdata,12,(uint32_t)file_size);
+                       SIVAL(pdata,16,(uint32_t)allocation_size);
                        SSVAL(pdata,20,mode);
                        SIVAL(pdata,22,ea_size);
                        break;
@@ -5106,8 +5254,8 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        {
                                SMB_ACL_T file_acl = NULL;
                                SMB_ACL_T def_acl = NULL;
-                               uint16 num_file_acls = 0;
-                               uint16 num_def_acls = 0;
+                               uint16_t num_file_acls = 0;
+                               uint16_t num_def_acls = 0;
 
                                if (fsp && fsp->fh->fd != -1) {
                                        file_acl = SMB_VFS_SYS_ACL_GET_FD(fsp,
@@ -5282,7 +5430,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
 {
        char *params = *pparams;
        char *pdata = *ppdata;
-       uint16 info_level;
+       uint16_t info_level;
        unsigned int data_size = 0;
        unsigned int param_size = 2;
        struct smb_filename *smb_fname = NULL;
@@ -5554,7 +5702,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                case SMB_INFO_QUERY_EAS_FROM_LIST:
                {
                        /* Pull any EA list from the data portion. */
-                       uint32 ea_size;
+                       uint32_t ea_size;
 
                        if (total_data < 4) {
                                reply_nterror(
@@ -5745,7 +5893,7 @@ NTSTATUS smb_set_file_time(connection_struct *conn,
                           bool setting_write_time)
 {
        struct smb_filename smb_fname_base;
-       uint32 action =
+       uint32_t action =
                FILE_NOTIFY_CHANGE_LAST_ACCESS
                |FILE_NOTIFY_CHANGE_LAST_WRITE
                |FILE_NOTIFY_CHANGE_CREATION;
@@ -5840,7 +5988,7 @@ NTSTATUS smb_set_file_time(connection_struct *conn,
 
 static NTSTATUS smb_set_file_dosmode(connection_struct *conn,
                                     const struct smb_filename *smb_fname,
-                                    uint32 dosmode)
+                                    uint32_t dosmode)
 {
        struct smb_filename *smb_fname_base;
        NTSTATUS status;
@@ -5955,7 +6103,8 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &new_fsp,                               /* result */
-               NULL);                                  /* pinfo */
+               NULL,                                   /* pinfo */
+               NULL, NULL);                            /* create context */
 
        TALLOC_FREE(smb_fname_tmp);
 
@@ -6085,7 +6234,7 @@ static NTSTATUS smb_set_file_disposition_info(connection_struct *conn,
 {
        NTSTATUS status = NT_STATUS_OK;
        bool delete_on_close;
-       uint32 dosmode = 0;
+       uint32_t dosmode = 0;
 
        if (total_data < 1) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -6158,7 +6307,7 @@ static NTSTATUS smb_file_mode_information(connection_struct *conn,
                                const char *pdata,
                                int total_data)
 {
-       uint32 mode;
+       uint32_t mode;
 
        if (total_data < 4) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -6432,8 +6581,8 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                                            struct smb_filename *smb_fname_src)
 {
        bool overwrite;
-       uint32 root_fid;
-       uint32 len;
+       uint32_t root_fid;
+       uint32_t len;
        char *newname = NULL;
        struct smb_filename *smb_fname_dst = NULL;
        bool dest_has_wcard = False;
@@ -6600,9 +6749,9 @@ static NTSTATUS smb_set_posix_acl(connection_struct *conn,
                                files_struct *fsp,
                                const struct smb_filename *smb_fname)
 {
-       uint16 posix_acl_version;
-       uint16 num_file_acls;
-       uint16 num_def_acls;
+       uint16_t posix_acl_version;
+       uint16_t num_file_acls;
+       uint16_t num_def_acls;
        bool valid_file_acls = True;
        bool valid_def_acls = True;
 
@@ -6783,7 +6932,7 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn,
 {
        /* Patch to do this correctly from Paul Eggert <eggert@twinsun.com>. */
        struct smb_file_time ft;
-       uint32 dosmode = 0;
+       uint32_t dosmode = 0;
        NTSTATUS status = NT_STATUS_OK;
 
        ZERO_STRUCT(ft);
@@ -6941,7 +7090,8 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &new_fsp,                               /* result */
-               NULL);                                  /* pinfo */
+               NULL,                                   /* pinfo */
+               NULL, NULL);                            /* create context */
 
        if (!NT_STATUS_IS_OK(status)) {
                /* NB. We check for open_was_deferred in the caller. */
@@ -7008,13 +7158,13 @@ static NTSTATUS smb_unix_mknod(connection_struct *conn,
                                        int total_data,
                                        const struct smb_filename *smb_fname)
 {
-       uint32 file_type = IVAL(pdata,56);
+       uint32_t file_type = IVAL(pdata,56);
 #if defined(HAVE_MAKEDEV)
-       uint32 dev_major = IVAL(pdata,60);
-       uint32 dev_minor = IVAL(pdata,68);
+       uint32_t dev_major = IVAL(pdata,60);
+       uint32_t dev_minor = IVAL(pdata,68);
 #endif
        SMB_DEV_T dev = (SMB_DEV_T)0;
-       uint32 raw_unixmode = IVAL(pdata,84);
+       uint32_t raw_unixmode = IVAL(pdata,84);
        NTSTATUS status;
        mode_t unixmode;
 
@@ -7096,7 +7246,7 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn,
                                        const struct smb_filename *smb_fname)
 {
        struct smb_file_time ft;
-       uint32 raw_unixmode;
+       uint32_t raw_unixmode;
        mode_t unixmode;
        off_t size = 0;
        uid_t set_owner = (uid_t)SMB_UID_NO_CHANGE;
@@ -7352,8 +7502,8 @@ static NTSTATUS smb_set_file_unix_info2(connection_struct *conn,
                                        const struct smb_filename *smb_fname)
 {
        NTSTATUS status;
-       uint32 smb_fflags;
-       uint32 smb_fmask;
+       uint32_t smb_fflags;
+       uint32_t smb_fmask;
 
        if (total_data < 116) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -7414,11 +7564,11 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
                                int *pdata_return_size)
 {
        NTSTATUS status = NT_STATUS_OK;
-       uint32 raw_unixmode = 0;
-       uint32 mod_unixmode = 0;
+       uint32_t raw_unixmode = 0;
+       uint32_t mod_unixmode = 0;
        mode_t unixmode = (mode_t)0;
        files_struct *fsp = NULL;
-       uint16 info_level_return = 0;
+       uint16_t info_level_return = 0;
        int info;
        char *pdata = *ppdata;
 
@@ -7435,7 +7585,7 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
                return status;
        }
 
-       mod_unixmode = (uint32)unixmode | FILE_FLAG_POSIX_SEMANTICS;
+       mod_unixmode = (uint32_t)unixmode | FILE_FLAG_POSIX_SEMANTICS;
 
        DEBUG(10,("smb_posix_mkdir: file %s, mode 0%o\n",
                  smb_fname_str_dbg(smb_fname), (unsigned int)unixmode));
@@ -7457,7 +7607,8 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
-               &info);                                 /* pinfo */
+               &info,                                  /* pinfo */
+               NULL, NULL);                            /* create context */
 
         if (NT_STATUS_IS_OK(status)) {
                 close_file(req, fsp, NORMAL_CLOSE);
@@ -7523,19 +7674,19 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
 {
        bool extended_oplock_granted = False;
        char *pdata = *ppdata;
-       uint32 flags = 0;
-       uint32 wire_open_mode = 0;
-       uint32 raw_unixmode = 0;
-       uint32 mod_unixmode = 0;
-       uint32 create_disp = 0;
-       uint32 access_mask = 0;
-       uint32 create_options = FILE_NON_DIRECTORY_FILE;
+       uint32_t flags = 0;
+       uint32_t wire_open_mode = 0;
+       uint32_t raw_unixmode = 0;
+       uint32_t mod_unixmode = 0;
+       uint32_t create_disp = 0;
+       uint32_t access_mask = 0;
+       uint32_t create_options = FILE_NON_DIRECTORY_FILE;
        NTSTATUS status = NT_STATUS_OK;
        mode_t unixmode = (mode_t)0;
        files_struct *fsp = NULL;
        int oplock_request = 0;
        int info = 0;
-       uint16 info_level_return = 0;
+       uint16_t info_level_return = 0;
 
        if (total_data < 18) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -7646,7 +7797,7 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
                return status;
        }
 
-       mod_unixmode = (uint32)unixmode | FILE_FLAG_POSIX_SEMANTICS;
+       mod_unixmode = (uint32_t)unixmode | FILE_FLAG_POSIX_SEMANTICS;
 
        if (wire_open_mode & SMB_O_SYNC) {
                create_options |= FILE_WRITE_THROUGH;
@@ -7690,7 +7841,8 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
-               &info);                                 /* pinfo */
+               &info,                                  /* pinfo */
+               NULL, NULL);                            /* create context */
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -7773,7 +7925,7 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
 {
        NTSTATUS status = NT_STATUS_OK;
        files_struct *fsp = NULL;
-       uint16 flags = 0;
+       uint16_t flags = 0;
        char del = 1;
        int info = 0;
        int create_options = 0;
@@ -7821,7 +7973,8 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
-               &info);                                 /* pinfo */
+               &info,                                  /* pinfo */
+               NULL, NULL);                            /* create context */
 
        if (!NT_STATUS_IS_OK(status)) {
                return status;
@@ -8177,7 +8330,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
 {
        char *params = *pparams;
        char *pdata = *ppdata;
-       uint16 info_level;
+       uint16_t info_level;
        struct smb_filename *smb_fname = NULL;
        files_struct *fsp = NULL;
        NTSTATUS status = NT_STATUS_OK;
@@ -8351,7 +8504,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                                         ppdata, total_data,
                                         &data_return_size);
        if (!NT_STATUS_IS_OK(status)) {
-               if (open_was_deferred(req->sconn, req->mid)) {
+               if (open_was_deferred(req->xconn, req->mid)) {
                        /* We have re-scheduled this call. */
                        return;
                }
@@ -8526,7 +8679,7 @@ static void call_trans2findnotifyfirst(connection_struct *conn,
                                       unsigned int max_data_bytes)
 {
        char *params = *pparams;
-       uint16 info_level;
+       uint16_t info_level;
 
        if (total_params < 6) {
                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);