Add ea_list_has_invalid_name() function.
authorJeremy Allison <jra@samba.org>
Tue, 9 Jul 2013 22:50:47 +0000 (15:50 -0700)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 19 Jul 2013 07:52:32 +0000 (17:52 +1000)
Invalid character list probed from Windows Server 2012.

Bug 9992: Windows error 0x800700FE when copying files with xattr names containing ":"

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/include/proto.h
source3/lib/filename_util.c

index 83ab77a2a9df5894a9bf6c151826f52e0846f76b..a9270fc903486a9c800fadc5d768dfd58bf0b09e 100644 (file)
@@ -1611,6 +1611,8 @@ struct smb_filename *cp_smb_filename(TALLOC_CTX *mem_ctx,
                                     const struct smb_filename *in);
 bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname);
 bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname);
+bool is_invalid_windows_ea_name(const char *name);
+bool ea_list_has_invalid_name(struct ea_list *ea_list);
 
 /* The following definitions come from lib/dummyroot.c */
 
index 656dd2abceed946e5ea4500072692835cbf3a7b0..19ffcc3638933f3d27b934fd9a7da867de79c799 100644 (file)
@@ -224,3 +224,37 @@ bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname)
 
        return strcasecmp_m(smb_fname->stream_name, "::$DATA") == 0;
 }
+
+/****************************************************************************
+ Filter out Windows invalid EA names (list probed from Windows 2012).
+****************************************************************************/
+
+static char bad_ea_name_chars[] = "\"*+,/:;<=>?[\\]|";
+
+bool is_invalid_windows_ea_name(const char *name)
+{
+       int i;
+       /* EA name is pulled as ascii so we can examine
+          individual bytes here. */
+       for (i = 0; name[i] != 0; i++) {
+               int val = (name[i] & 0xff);
+               if (val < ' ' || strchr(bad_ea_name_chars, val)) {
+                       return true;
+               }
+       }
+       return false;
+}
+
+bool ea_list_has_invalid_name(struct ea_list *ea_list)
+{
+       if (lp_posix_pathnames()) {
+               return false;
+       }
+
+       for (;ea_list; ea_list = ea_list->next) {
+               if (is_invalid_windows_ea_name(ea_list->ea.name)) {
+                       return true;
+               }
+       }
+       return false;
+}