diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-01-24 13:31:34 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-01-24 13:31:34 +0000 |
commit | dfed852520e3f7412576cb246198780d0993e7ea (patch) | |
tree | bd7b3a3741c44b52be14854978fb4b86cbb176eb /source3/smbd | |
parent | 723b368dc20b6075055cc0e7177990c1b6391041 (diff) | |
download | samba-dfed852520e3f7412576cb246198780d0993e7ea.tar.gz samba-dfed852520e3f7412576cb246198780d0993e7ea.tar.bz2 samba-dfed852520e3f7412576cb246198780d0993e7ea.zip |
handle filenames like .bashrc better in the new mangling code
(This used to be commit 05adb30eabceea0ebbd7a7831533e2d4f20e58c8)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/mangle.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/source3/smbd/mangle.c b/source3/smbd/mangle.c index cfa2792395..b83168712f 100644 --- a/source3/smbd/mangle.c +++ b/source3/smbd/mangle.c @@ -81,13 +81,14 @@ static int ucs2_to_dos(char *dest, const smb_ucs2_t *src, int dest_len) return ret; } -/* trasform in a string that contain only valid chars for win filenames */ +/* trasform in a string that contain only valid chars for win filenames, + not including a '.' */ static void strvalid(smb_ucs2_t *src) { if (!src || !*src) return; while (*src) { - if (!isvalid83_w(*src)) *src = UCS2_CHAR('_'); + if (!isvalid83_w(*src) || *src == UCS2_CHAR('.')) *src = UCS2_CHAR('_'); src++; } } @@ -110,13 +111,12 @@ static NTSTATUS mangle_get_prefix(const smb_ucs2_t *ucs2_string, smb_ucs2_t **pr } if ((p = strrchr_w(*prefix, UCS2_CHAR('.')))) { - p++; - ext_len = strlen_w(p); - if ((ext_len > 0) && (ext_len < 4) - && (NT_STATUS_IS_OK(has_valid_chars(p)))) /* check extension */ + ext_len = strlen_w(p+1); + if ((ext_len > 0) && (ext_len < 4) && (p != *prefix) && + (NT_STATUS_IS_OK(has_valid_chars(p+1)))) /* check extension */ { - *(p - 1) = 0; - *extension = strdup_w(p); + *p = 0; + *extension = strdup_w(p+1); if (!*extension) { DEBUG(0,("mangle_get_prefix: out of memory!\n")); @@ -584,6 +584,8 @@ NTSTATUS is_8_3_w(const smb_ucs2_t *fname) if (NT_STATUS_IS_ERR(mangle_get_prefix(fname, &pref, &ext))) goto done; plen = strlen_w(pref); + + if (strchr_wa(pref, '.')) goto done; if (plen < 1 || plen > 8) goto done; if (ext) if (strlen_w(ext) > 3) goto done; @@ -623,6 +625,8 @@ NTSTATUS is_valid_name(const smb_ucs2_t *fname) if (!fname || !*fname) return NT_STATUS_INVALID_PARAMETER; DEBUG(10,("is_valid_name: testing\n")); /* [%s]\n", s)); */ + + if (*fname == UCS2_CHAR('.')) return NT_STATUS_UNSUCCESSFUL; ret = has_valid_chars(fname); if (NT_STATUS_IS_ERR(ret)) return ret; |