r6977: Fix bug #2735 (not mangling control characters) plus
authorJeremy Allison <jra@samba.org>
Wed, 25 May 2005 19:25:35 +0000 (19:25 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:56:59 +0000 (10:56 -0500)
ensure we don't create files with control characters
either.
Jeremy.
(This used to be commit 0ca2423c706423a07721e375345b6d45a45cbcf4)

source3/smbd/mangle_hash.c
source3/smbd/mangle_hash2.c
source3/smbd/reply.c

index fee386d6db951165cc3839114b9cc5cea084e088..871702623a8218498cc4aacd291e4ed3ea487ebe 100644 (file)
@@ -95,6 +95,10 @@ static NTSTATUS has_illegal_chars(const smb_ucs2_t *s, BOOL allow_wildcards)
        }
 
        while (*s) {
+               if (*s <= 0x1f) {
+                       /* Control characters. */
+                       return NT_STATUS_UNSUCCESSFUL;
+               }
                switch(*s) {
                        case UCS2_CHAR('\\'):
                        case UCS2_CHAR('/'):
index 6a8462ee3d06a5ccd81054366304951c404f7052..4325c07f580e785cd6476a2dc134732807c4a757 100644 (file)
@@ -633,6 +633,11 @@ static void init_tables(void)
        memset(char_flags, 0, sizeof(char_flags));
 
        for (i=1;i<128;i++) {
+               if (i <= 0x1f) {
+                       /* Control characters. */
+                       char_flags[i] |= FLAG_ILLEGAL;
+               }
+
                if ((i >= '0' && i <= '9') || 
                    (i >= 'a' && i <= 'z') || 
                    (i >= 'A' && i <= 'Z')) {
index 686f54c5e714c8b6f4a19cee3b0a4d069855a011..1c2e950836769a94064e070f8a3b992a613ae70d 100644 (file)
@@ -118,6 +118,9 @@ NTSTATUS check_path_syntax(pstring destname, const pstring srcname)
                }
 
                if (!(*s & 0x80)) {
+                       if (*s <= 0x1f) {
+                               return NT_STATUS_OBJECT_NAME_INVALID;
+                       }
                        switch (*s) {
                                case '*':
                                case '?':
@@ -244,6 +247,9 @@ NTSTATUS check_path_syntax_wcard(pstring destname, const pstring srcname)
                }
 
                if (!(*s & 0x80)) {
+                       if (*s <= 0x1f) {
+                               return NT_STATUS_OBJECT_NAME_INVALID;
+                       }
                        *d++ = *s++;
                } else {
                        switch(next_mb_char_size(s)) {