]> arthur.barton.de Git - netatalk.git/commitdiff
deal with AFP3 connection but type 2 (not UTF8 encoding) name.
authordidg <didg>
Tue, 7 Dec 2004 02:58:08 +0000 (02:58 +0000)
committerdidg <didg>
Tue, 7 Dec 2004 02:58:08 +0000 (02:58 +0000)
etc/afpd/directory.c
etc/afpd/file.c
etc/afpd/file.h
etc/afpd/filedir.c

index 9f19652a6fe23242a2fa14555d4832fd12ce44c8..e22c7c949a52480d32efbcb8a1a93b9295d96cc1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.71.2.4.2.15.2.1 2004-10-20 21:43:33 didg Exp $
+ * $Id: directory.c,v 1.71.2.4.2.15.2.2 2004-12-07 02:58:10 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -979,6 +979,7 @@ char        **cpath;
     u_int16_t   len16;
     int         size = 0;
     char        sep;
+    int         toUTF8 = 0;
                
     data = *cpath;
     afp_errno = AFPERR_NOOBJ;
@@ -988,6 +989,10 @@ char       **cpath;
        len = (unsigned char) *data++;
        size = 2;
        sep = 0;
+       if (afp_version >= 30) {
+           ret.m_type = 3;
+           toUTF8 = 1;
+       }
        break;
     case 3:
        if (afp_version >= 30) {
@@ -1104,9 +1109,20 @@ char     **cpath;
         if ( p != path ) { /* we got something */
             ret.u_name = NULL;
             if (afp_version >= 30) {
-                /* check for OS X mangled filename :( */
                 char *t;
                 cnid_t fileid;
+                
+                if (toUTF8) {
+                    static char        temp[ MAXPATHLEN + 1];
+
+                    /* not an UTF8 name */
+                    if (mtoUTF8(vol, path, strlen(path), temp, MAXPATHLEN) == -1) {
+                        afp_errno = AFPERR_PARAM;
+                        return( NULL );
+                    }
+                    strcpy(path, temp);
+                }
+                /* check for OS X mangled filename :( */
            
                 t = demangle_osx(vol, path, dir->d_did, &fileid);
                 if (t != path) {
index 52fc185e78dd1173f74c26ab9c6a7ee355217b71..09502efa000223ef6353a8a5bb293503b5d2b28e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.c,v 1.92.2.2.2.31.2.3 2004-10-30 21:43:46 didg Exp $
+ * $Id: file.c,v 1.92.2.2.2.31.2.4 2004-12-07 02:58:09 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1127,7 +1127,21 @@ struct adouble    *adp;
     return( AFP_OK );
 }
 
-int copy_path_name(char *newname, char *ibuf)
+/* ---------------- 
+   convert a Mac long name to an utf8 name,
+*/
+size_t mtoUTF8(const struct vol *vol, const char *src, size_t srclen, char *dest, size_t destlen)
+{
+size_t    outlen;
+
+    if ((size_t)-1 == (outlen = convert_string ( vol->v_maccharset, CH_UTF8_MAC, src, srclen, dest, destlen)) ) {
+       return -1;
+    }
+    return outlen;
+}
+
+/* ---------------- */
+int copy_path_name(const struct vol *vol, char *newname, char *ibuf)
 {
 char        type = *ibuf;
 size_t      plen = 0;
@@ -1141,8 +1155,16 @@ u_int32_t   hint;
     switch (type) {
     case 2:
         if (( plen = (unsigned char)*ibuf++ ) != 0 ) {
-            strncpy( newname, ibuf, plen );
-            newname[ plen ] = '\0';
+            if (afp_version >= 30) {
+                /* convert it to UTF8 
+                */
+                if ((plen = mtoUTF8(vol, ibuf, plen, newname, AFPOBJ_TMPSIZ)) == -1)
+                   return -1;
+            }
+            else {
+                strncpy( newname, ibuf, plen );
+                newname[ plen ] = '\0';
+            }
             if (strlen(newname) != plen) {
                 /* there's \0 in newname, e.g. it's a pathname not
                  * only a filename. 
@@ -1259,7 +1281,7 @@ int               ibuflen, *rbuflen;
     }
 
     /* one of the handful of places that knows about the path type */
-    if (copy_path_name(newname, ibuf) < 0) {
+    if (copy_path_name(d_vol, newname, ibuf) < 0) {
         return( AFPERR_PARAM );
     }
     /* newname is always only a filename so curdir *is* its
index 1e66e70b49830ede032865840de009f1f0e59349..dc0ddb83ac9b53b61f81f6cdcd6da52a9176c693 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.h,v 1.16.2.2.2.3 2004-03-11 02:02:01 didg Exp $
+ * $Id: file.h,v 1.16.2.2.2.3.2.1 2004-12-07 02:58:09 didg Exp $
  *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
@@ -134,7 +134,9 @@ extern int copyfile     __P((const struct vol *, const struct vol *, char *, cha
 extern int deletefile   __P((const struct vol *, char *, int));
 
 extern void *get_finderinfo __P((const char *, struct adouble *, void *));
-extern int  copy_path_name __P((char *, char *i));
+
+extern size_t mtoUTF8   __P((const struct vol *, const char *, size_t , char *, size_t ));
+extern int  copy_path_name __P((const struct vol *, char *, char *i));
 
 extern u_int32_t get_id  __P((struct vol *, struct adouble *, const struct stat *,
                                 const cnid_t , const char *, const int ));
index 12bede5784d3c02cd6ba05c14f0ce303f24f44f7..8555cadac82e8c4059e23f2f023d122a02ca275f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.45.2.2.2.14 2004-10-06 20:05:14 bfernhomberg Exp $
+ * $Id: filedir.c,v 1.45.2.2.2.14.2.1 2004-12-07 02:58:08 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -503,7 +503,7 @@ int         ibuflen, *rbuflen;
     }
 
     /* another place where we know about the path type */
-    if ((plen = copy_path_name(newname, ibuf)) < 0) {
+    if ((plen = copy_path_name(vol, newname, ibuf)) < 0) {
         return( AFPERR_PARAM );
     }
 
@@ -719,7 +719,7 @@ int         ibuflen, *rbuflen;
     }
 
     /* one more place where we know about path type */
-    if ((plen = copy_path_name(newname, ibuf)) < 0) {
+    if ((plen = copy_path_name(vol, newname, ibuf)) < 0) {
         return( AFPERR_PARAM );
     }