]> arthur.barton.de Git - netatalk.git/commitdiff
replace 255 with UTF8FILELEN_EARLY
authorHAT <hat@fa2.so-net.ne.jp>
Fri, 4 Mar 2011 18:14:41 +0000 (03:14 +0900)
committerHAT <hat@fa2.so-net.ne.jp>
Fri, 4 Mar 2011 18:14:41 +0000 (03:14 +0900)
etc/afpd/catsearch.c
etc/afpd/directory.c
etc/afpd/enumerate.c
etc/afpd/file.c
etc/afpd/globals.h
etc/afpd/mangle.c
etc/afpd/ofork.c
etc/afpd/volume.c

index 0faeef9494b92619dd6cbcf2f905d6ce88a12dd8..80e807ca4ff136225c8e0da57d920d254e9bae2e 100644 (file)
@@ -1014,8 +1014,8 @@ static int catsearch_afp(AFPObj *obj _U_, char *ibuf, size_t ibuflen,
                /* length */
                memcpy(&namelen, spec1, sizeof(namelen));
                namelen = ntohs (namelen);
-               if (namelen > 255)  /* Safeguard */
-                       namelen = 255;
+               if (namelen > UTF8FILELEN_EARLY)  /* Safeguard */
+                       namelen = UTF8FILELEN_EARLY;
 
                memcpy (c1.utf8name, spec1+2, namelen);
                c1.utf8name[namelen] = 0;
index d4db9ece71c425ce7d02f11605fa1c48993bb6c9..cdf9574158f261250da4f55b5446357a9a4eb601 100644 (file)
@@ -1104,7 +1104,7 @@ struct path *cname(struct vol *vol, struct dir *dir, char **cpath)
         /* 6*/
         for ( p = path; *data != 0 && len > 0; len-- ) {
             *p++ = *data++;
-            if (p > &path[255]) {   /* FIXME safeguard, limit of early Mac OS X */
+            if (p > &path[UTF8FILELEN_EARLY]) {   /* FIXME safeguard, limit of early Mac OS X */
                 afp_errno = AFPERR_PARAM;
                 return NULL;
             }
index 79869dbd0d84fc3256ca7ec8999b02a323f1950f..edccf39af8ddc812a9e262ceca839d725b2d1d56 100644 (file)
@@ -155,7 +155,7 @@ for_each_dirent(const struct vol *vol, char *name, dir_loop fn, void *data)
    macnamelength(1) + macname(31) + utf8(4) + utf8namelen(2) + utf8name(255) +
    oddpadding(1) */
 
-#define REPLY_PARAM_MAXLEN (4 + 104 + 1 + MACFILELEN + 4 + 2 + 255 + 1)
+#define REPLY_PARAM_MAXLEN (4 + 104 + 1 + MACFILELEN + 4 + 2 + UTF8FILELEN_EARLY + 1)
 
 /* ----------------------------- */
 static int enumerate(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, 
index d3bf5600b36e1f68c91a15d3b1fadfe2eaa73f71..434d9b5c0f56e4be1a7812a77bf4410a97121404 100644 (file)
@@ -165,8 +165,8 @@ char *set_name(const struct vol *vol, char *data, cnid_t pid, char *name, cnid_t
     else {
         u_int16_t temp;
 
-        if (aint > 255)  /* FIXME safeguard, anyway if no ascii char it's game over*/
-           aint = 255;
+        if (aint > UTF8FILELEN_EARLY)  /* FIXME safeguard, anyway if no ascii char it's game over*/
+           aint = UTF8FILELEN_EARLY;
 
         utf8 = vol->v_kTextEncoding;
         memcpy(data, &utf8, sizeof(utf8));
index 4b6cea4ae0ca80cfa41a69935531a68af66c9cce..9b6465143a20facec691050e4a31bf9aa9580125 100644 (file)
 #include <atalk/unicode.h>
 #include <atalk/uam.h>
 
-#define MACFILELEN 31
+/* #define DOSFILELEN 12 */             /* Type1, DOS-compat*/
+#define MACFILELEN 31                   /* Type2, HFS-compat */
+#define UTF8FILELEN_EARLY 255           /* Type3, early Mac OS X 10.0-10.4.? */
+/* #define UTF8FILELEN_NAME_MAX 765 */  /* Type3, 10.4.?- , getconf NAME_MAX */
+/* #define UTF8FILELEN_SPEC 0xFFFF */   /* Type3, spec on document */
+/* #define HFSPLUSFILELEN 510 */        /* HFS+ spec, 510byte = 255codepoint */
+
 #define MAXUSERLEN 256
 
 #define OPTION_DEBUG         (1 << 0)
index 91533e619a674d9748b5c1cc6f365c6d58952aae..cb2b60ed0c15e5bd63bb0cb1ca1c66e7a02089ba 100644 (file)
@@ -1,6 +1,4 @@
 /* 
- * $Id: mangle.c,v 1.19.4.2 2010-02-01 14:25:45 franklahm Exp $ 
- *
  * Copyright (c) 2002. Joe Marcus Clarke (marcus@marcuscom.com)
  * All Rights Reserved.  See COPYRIGHT.
  *
@@ -225,13 +223,22 @@ demangle_osx(const struct vol *vol, char *mfilename, cnid_t did, cnid_t *fileid)
     return private_demangle(vol, mfilename, did, fileid);
 }
 
+/* -------------------------------------------------------
+   FIXME !!!
+
+   Early Mac OS X (10.0-10.4.?) had the limitation up to 255 Byte.
+   Current implementation is:
+      volcharset -> UTF16-MAC -> truncated 255 UTF8-MAC
+
+   Recent Mac OS X (10.4.?-) don't have this limitation.
+   Desirable implementation is:
+      volcharset -> truncated 510 UTF16-MAC -> UTF8-MAC
 
-/* -----------------------
+   ------------------------
    with utf8 filename not always round trip
    filename   mac filename too long or first chars if unmatchable chars.
    uname      unix filename 
    id         file/folder ID or 0
-   
 */
 char *
 mangle(const struct vol *vol, char *filename, size_t filenamelen, char *uname, cnid_t id, int flags) {
@@ -243,7 +250,7 @@ mangle(const struct vol *vol, char *filename, size_t filenamelen, char *uname, c
     size_t maxlen;
     int k;
     
-    maxlen = (flags & 2)?255:MACFILELEN; /* was vol->max_filename */
+    maxlen = (flags & 2)?UTF8FILELEN_EARLY:MACFILELEN; /* was vol->max_filename */
     /* Do we really need to mangle this filename? */
     if (!(flags & 1) && filenamelen <= maxlen) {
        return filename;
index f5f8a38de8d7fff65a380ac83674fe9c755c190a..a69a73c56c5de3d015f07858ea6d0e9b029ad3a9 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: ofork.c,v 1.32 2010/03/12 15:16:49 franklahm Exp $
- *
  * Copyright (c) 1996 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
@@ -213,7 +211,7 @@ of_alloc(struct vol *vol,
            ad_open really does reinitialize the structure. */
         ad_init(ad, vol->v_adouble, vol->v_ad_options);
 
-        ad->ad_m_namelen = 255 +1;
+        ad->ad_m_namelen = UTF8FILELEN_EARLY +1;
         /* here's the deal: we allocate enough for the standard mac file length.
          * in the future, we'll reallocate in fairly large jumps in case
          * of long unicode names */
index 7596a75013dcdb973538987337ac05cd67a7fe73..fc60d16d617b32a735c7223653df1ed0fcc3df26 100644 (file)
@@ -2152,7 +2152,7 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t
      * FIXME file size
      */
     if (utf8_encoding()) {
-        volume->max_filename = 255;
+        volume->max_filename = UTF8FILELEN_EARLY;
     }
     else {
         volume->max_filename = MACFILELEN;