r2575: Return correct error codes on old SEARCH call (from Samba4 torture tester).
authorJeremy Allison <jra@samba.org>
Fri, 24 Sep 2004 00:55:46 +0000 (00:55 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:52:47 +0000 (10:52 -0500)
Jeremy.
(This used to be commit fc51c97ea86bd1a86830d4ab2c6c7c4ec9fccc88)

source3/include/nterr.h
source3/libsmb/errormap.c
source3/libsmb/nterr.c
source3/smbd/reply.c

index 19c70cffcc9160fdd1b29c08304eeda6efe1baba..6cf5a756d297ae4aa3a1e6062b1a2728fa4437ed 100644 (file)
 /* Win32 Status codes. */
 
 #define STATUS_BUFFER_OVERFLOW            NT_STATUS(0x80000005)
+#define STATUS_NO_MORE_FILES              NT_STATUS(0x80000006)
 #define NT_STATUS_NO_MORE_ENTRIES         NT_STATUS(0x8000001a)
 
-#define STATUS_MORE_ENTRIES            NT_STATUS(0x0105)
+#define STATUS_MORE_ENTRIES               NT_STATUS(0x0105)
 #define STATUS_SOME_UNMAPPED              NT_STATUS(0x0107)
 #define ERROR_INVALID_PARAMETER                  NT_STATUS(0x0057)
 #define ERROR_INSUFFICIENT_BUFFER        NT_STATUS(0x007a)
index 77c71fce13c9ef7baf6c1b38c1299b59d691b5a2..8ac1aed923ba598bfc3d68ef6c0b760f53956879 100644 (file)
@@ -102,6 +102,7 @@ static const struct {
  * Not an official error, as only bit 0x80000000, not bits 0xC0000000 are set.
  */
        {ERRDOS,        ERRmoredata,    STATUS_BUFFER_OVERFLOW},
+       {ERRDOS,        ERRnofiles,     STATUS_NO_MORE_FILES},
        {ERRDOS,        ERRbadfid,      NT_STATUS_OBJECT_TYPE_MISMATCH},
        {ERRHRD,        ERRgeneral,     NT_STATUS_NONCONTINUABLE_EXCEPTION},
        {ERRHRD,        ERRgeneral,     NT_STATUS_INVALID_DISPOSITION},
@@ -632,7 +633,7 @@ static const struct {
        {ERRDOS,        14,     NT_STATUS_SECTION_NOT_EXTENDED},
        {ERRDOS,        ERRremcd,       NT_STATUS_DIRECTORY_NOT_EMPTY},
        {ERRDOS,        ERRdiffdevice,  NT_STATUS_NOT_SAME_DEVICE},
-       {ERRDOS,        ERRnofiles,     NT_STATUS(0x80000006)},
+       {ERRDOS,        ERRnofiles,     STATUS_NO_MORE_FILES},
        {ERRDOS,        19,     NT_STATUS_MEDIA_WRITE_PROTECTED},
        {ERRDOS,        21,     NT_STATUS_NO_MEDIA_IN_DEVICE},
        {ERRDOS,        22,     NT_STATUS_INVALID_DEVICE_STATE},
index b01451ea0fac1c18c11ef5f355020189fd7ec896..677c5d84c73c27786e6a4efe351b403a100848b4 100644 (file)
@@ -537,6 +537,7 @@ static nt_err_code_struct nt_errs[] =
         { "NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES },
        { "STATUS_MORE_ENTRIES", STATUS_MORE_ENTRIES },
        { "STATUS_SOME_UNMAPPED", STATUS_SOME_UNMAPPED },
+       { "STATUS_NO_MORE_FILES", STATUS_NO_MORE_FILES },
        { NULL, NT_STATUS(0) }
 };
 
@@ -634,14 +635,15 @@ nt_err_code_struct nt_err_desc[] =
        { "Insufficient logon information",     NT_STATUS_INSUFFICIENT_LOGON_INFO },
        
        { "License quota exceeded",             NT_STATUS_LICENSE_QUOTA_EXCEEDED },
+       { "No more files",                      STATUS_NO_MORE_FILES },
 
        { NULL, NT_STATUS(0) }
 };
 
-
 /*****************************************************************************
returns an NT error message.  not amazingly helpful, but better than a number.
Returns an NT error message.  not amazingly helpful, but better than a number.
  *****************************************************************************/
+
 const char *nt_errstr(NTSTATUS nt_code)
 {
         static pstring msg;
@@ -669,8 +671,7 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
         int idx = 0;
 
        while (nt_err_desc[idx].nt_errstr != NULL) {
-               if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) 
-               {
+               if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) {
                         return nt_err_desc[idx].nt_errstr;
                }
                idx++;
@@ -682,8 +683,9 @@ const char *get_friendly_nt_error_msg(NTSTATUS nt_code)
 }
 
 /*****************************************************************************
- returns an NT_STATUS constant as a string for inclusion in autogen C code
+ Returns an NT_STATUS constant as a string for inclusion in autogen C code.
  *****************************************************************************/
+
 const char *get_nt_error_c_code(NTSTATUS nt_code)
 {
         static pstring out;
@@ -703,8 +705,9 @@ const char *get_nt_error_c_code(NTSTATUS nt_code)
 }
 
 /*****************************************************************************
returns the NT_STATUS constant matching the string supplied (as an NTSTATUS)
Returns the NT_STATUS constant matching the string supplied (as an NTSTATUS)
  *****************************************************************************/
+
 NTSTATUS nt_status_string_to_code(char *nt_status_str)
 {
         int idx = 0;
@@ -718,7 +721,6 @@ NTSTATUS nt_status_string_to_code(char *nt_status_str)
        return NT_STATUS_UNSUCCESSFUL;
 }
 
-
 /**
  * Squash an NT_STATUS in line with security requirements.
  * In an attempt to avoid giving the whole game away when users
index 565046061ccf830d3645cf1e4809eb2b921525db..cdf607e27384d4dbc125dfe4f984afe3a6a2e2ec 100644 (file)
@@ -934,8 +934,8 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
                                                make_dir_struct(p,mask,fname,size,mode,date,conn->case_sensitive);
                                                dptr_fill(p+12,dptr_num);
                                                numentries++;
+                                               p += DIR_STRUCT_SIZE;
                                        }
-                                       p += DIR_STRUCT_SIZE;
                                }
                        }
                } /* if (ok ) */
@@ -949,18 +949,12 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
                (X/Open spec) */
 
        if(ok && expect_close && numentries == 0 && status_len == 0) {
-               if (Protocol < PROTOCOL_NT1) {
-                       SCVAL(outbuf,smb_rcls,ERRDOS);
-                       SSVAL(outbuf,smb_err,ERRnofiles);
-               }
-               /* Also close the dptr - we know it's gone */
+               /* Close the dptr - we know it's gone */
                dptr_close(&dptr_num);
+               return ERROR_BOTH(STATUS_NO_MORE_FILES,ERRDOS,ERRnofiles);
        } else if (numentries == 0 || !ok) {
-               if (Protocol < PROTOCOL_NT1) {
-                       SCVAL(outbuf,smb_rcls,ERRDOS);
-                       SSVAL(outbuf,smb_err,ERRnofiles);
-               }
                dptr_close(&dptr_num);
+               return ERROR_BOTH(STATUS_NO_MORE_FILES,ERRDOS,ERRnofiles);
        }
 
        /* If we were called as SMBfunique, then we can close the dirptr now ! */