]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/desktop.c
limit comments size to 128 bytes, cf. Adobe CS2 bug
[netatalk.git] / etc / afpd / desktop.c
index fcd764fa44b61b06a9ad64d14939e7a00570703a..91db9151c4b5dfd96565181be455e763b3e94279 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: desktop.c,v 1.32 2005-05-14 12:54:49 didg Exp $
+ * $Id: desktop.c,v 1.35 2006-09-18 09:22:25 didg Exp $
  *
  * See COPYRIGHT.
  *
@@ -315,6 +315,8 @@ static const u_char utag[] = { 0, 0, 0, 0 };
 static const u_char    ucreator[] = { 0, 0, 0, 0 };/* { 'U', 'N', 'I', 'X' };*/
 static const u_char    utype[] = { 0, 0, 0, 0 };/* { 'T', 'E', 'X', 'T' };*/
 static const short     usize = 256;
+
+#if 0
 static const u_char    uicon[] = {
     0x1F, 0xFF, 0xFC, 0x00, 0x10, 0x00, 0x06, 0x00,
     0x10, 0x00, 0x05, 0x00, 0x10, 0x00, 0x04, 0x80,
@@ -349,6 +351,7 @@ static const u_char uicon[] = {
     0x1F, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0xF0,
     0x1F, 0xFF, 0xFF, 0xF0, 0x1F, 0xFF, 0xFF, 0xF0,
 };
+#endif
 
 int afp_geticoninfo(obj, ibuf, ibuflen, rbuf, rbuflen )
 AFPObj  *obj _U_;
@@ -454,6 +457,7 @@ int ibuflen _U_, *rbuflen;
     memcpy( &bsize, ibuf, sizeof( bsize ));
     bsize = ntohs( bsize );
 
+#if 0
     if ( memcmp( fcreator, ucreator, sizeof( ucreator )) == 0 &&
             memcmp( ftype, utype, sizeof( utype )) == 0 &&
             itype == 1 &&
@@ -462,6 +466,7 @@ int ibuflen _U_, *rbuflen;
         *rbuflen = bsize;
         return( AFP_OK );
     }
+#endif
 
     if ( iconopen( vol, fcreator, O_RDONLY, 0 ) < 0) {
         return( AFPERR_NOITEM );
@@ -806,7 +811,7 @@ static int ad_getcomment(struct vol *vol, struct path *path, char *rbuf, int *rb
     struct ofork        *of;
     char               *upath;
     int                 isadir;
-
+    int                        clen;
 
     upath = path->u_name;
     isadir = path_isadir(path);
@@ -821,6 +826,7 @@ static int ad_getcomment(struct vol *vol, struct path *path, char *rbuf, int *rb
     }
 
     if (!ad_getentryoff(adp, ADEID_COMMENT)) {
+        ad_close_metadata( adp );
         return AFPERR_NOITEM;
     }
     /*
@@ -832,9 +838,10 @@ static int ad_getcomment(struct vol *vol, struct path *path, char *rbuf, int *rb
         return( AFPERR_NOITEM );
     }
 
-    *rbuf++ = ad_getentrylen( adp, ADEID_COMMENT );
-    memcpy( rbuf, ad_entry( adp, ADEID_COMMENT ), ad_getentrylen( adp, ADEID_COMMENT ));
-    *rbuflen = ad_getentrylen( adp, ADEID_COMMENT ) + 1;
+    clen = min( ad_getentrylen( adp, ADEID_COMMENT ), 128 ); /* OSX only use 128, greater kill Adobe CS2 */
+    *rbuf++ = clen;
+    memcpy( rbuf, ad_entry( adp, ADEID_COMMENT ), clen);
+    *rbuflen = clen + 1;
     ad_close_metadata( adp);
 
     return( AFP_OK );