]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/catsearch.c
compute the right size if len == -1 in convert_string and use -1 than strlen(in)...
[netatalk.git] / etc / afpd / catsearch.c
index 8bc9adbed8e38933505fa9c7ebf638515e9bda46..82d66adc87a160b75b24153e29ae0eb3798788a9 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <dirent.h>
 #include <errno.h>
 #include <ctype.h>
 #include <string.h>
@@ -302,7 +301,7 @@ static int crit_check(struct vol *vol, struct path *path) {
 
        /* Check for filename */
        if ((c1.rbitmap & (1<<DIRPBIT_LNAME))) { 
-               if ( (size_t)(-1) == (len = convert_string(vol->v_maccharset, CH_UCS2, path->m_name, strlen(path->m_name), convbuf, 512)) )
+               if ( (size_t)(-1) == (len = convert_string(vol->v_maccharset, CH_UCS2, path->m_name, -1, convbuf, 512)) )
                        goto crit_check_ret;
 
                if ((c1.rbitmap & (1<<CATPBIT_PARTIAL))) {
@@ -736,8 +735,8 @@ static int catsearch_afp(AFPObj *obj _U_, char *ibuf, size_t ibuflen,
     }
 
     /* Parse file specifications */
-    spec1 = ibuf;
-    spec2 = ibuf + spec_len + 2;
+    spec1 = (unsigned char*)ibuf;
+    spec2 = (unsigned char*)ibuf + spec_len + 2;
 
     spec1 += 2; 
     spec2 += 2; 
@@ -827,7 +826,7 @@ static int catsearch_afp(AFPObj *obj _U_, char *ibuf, size_t ibuflen,
         /* Get the long filename */    
                memcpy(tmppath, bspec1 + spec1[1] + 1, (bspec1 + spec1[1])[0]);
                tmppath[(bspec1 + spec1[1])[0]]= 0;
-               len = convert_string ( vol->v_maccharset, CH_UCS2, tmppath, strlen(tmppath), c1.lname, sizeof(c1.lname));
+               len = convert_string ( vol->v_maccharset, CH_UCS2, tmppath, -1, c1.lname, sizeof(c1.lname));
         if (len == (size_t)(-1))
             return AFPERR_PARAM;