From 7dee710dd46b9999b2ffcaffcda82a40e4bf846f Mon Sep 17 00:00:00 2001 From: didg Date: Mon, 9 Jun 2003 11:44:30 +0000 Subject: [PATCH] =?utf8?q?backport=20catsearch=20fix=20from=20head,=20Bj?= =?utf8?q?=F6rn=20Fernhomberg.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- NEWS | 1 + etc/afpd/catsearch.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index cd457e48..3a4ac4f3 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ Changes in 1.6.3 ================ +* FIX: afpd: Catsearch, when Mac and unix name differ, search on attributes. * FIX: afpd: Files could be opened for writing on read-only filesystems. * FIX: afpd: Debugging using SIGUSR1 was broken. [Stefan Muenkner] * FIX: shell_utils: Don't distribute generated files. diff --git a/etc/afpd/catsearch.c b/etc/afpd/catsearch.c index 24f31f4c..095c2d5a 100644 --- a/etc/afpd/catsearch.c +++ b/etc/afpd/catsearch.c @@ -194,6 +194,7 @@ static int resolve_dir(struct vol *vol, int cidx) { struct dir *dir, *curdir; struct stat statbuf; + char* mname = NULL; if (dstack[cidx].dir != NULL) return 1; @@ -218,7 +219,8 @@ static int resolve_dir(struct vol *vol, int cidx) return 0; } - if (!dir && ((dir = adddir(vol, curdir, dstack[cidx].lname, strlen(dstack[cidx].lname), + mname = utompath(vol, dstack[cidx].lname); + if (!dir && ((dir = adddir(vol, curdir, mname, strlen(mname), dstack[cidx].path, strlen(dstack[cidx].path), &statbuf)) == NULL)) return 0; dstack[cidx].dir = dir; @@ -381,7 +383,8 @@ crit_check_ret: static int rslt_add(struct vol *vol, struct stat *statbuf, char *fname, short cidx, int isdir, char **rbuf) { char *p = *rbuf; - int l = fname != NULL ? strlen(fname) : 0; + char *savefname = (fname != NULL) ? strdup (fname) : NULL; + int l = savefname != NULL ? strlen(savefname) : 0; u_int32_t did; char p0; @@ -398,11 +401,11 @@ static int rslt_add(struct vol *vol, struct stat *statbuf, char *fname, short ci } /* Fill offset of returned file name */ - if (fname != NULL) { + if (savefname != NULL) { *p++ = 0; *p++ = (int)(p - *rbuf) - 1; p[0] = l; - strcpy(p+1, fname); + strcpy(p+1, savefname); p += l + 1; } @@ -411,6 +414,7 @@ static int rslt_add(struct vol *vol, struct stat *statbuf, char *fname, short ci *rbuf = p; /* *rbuf[0] = (int)(p-*rbuf); */ + free (savefname); return 1; } /* rslt_add */ @@ -633,10 +637,10 @@ int afp_catsearch(AFPObj *obj, char *ibuf, int ibuflen, /* File attribute bits... */ if (c1.rbitmap & (1 << FILPBIT_ATTR)) { - memcpy(&c1.attr, ibuf, sizeof(c1.attr)); + memcpy(&c1.attr, spec1, sizeof(c1.attr)); spec1 += sizeof(c1.attr); c1.attr = ntohs(c1.attr); - memcpy(&c2.attr, ibuf, sizeof(c2.attr)); + memcpy(&c2.attr, spec2, sizeof(c2.attr)); spec2 += sizeof(c1.attr); c2.attr = ntohs(c2.attr); } @@ -681,7 +685,7 @@ int afp_catsearch(AFPObj *obj, char *ibuf, int ibuflen, } /* Finder info */ - if (c1.rbitmap * (1 << FILPBIT_FINFO)) { + if (c1.rbitmap & (1 << FILPBIT_FINFO)) { memcpy(&c1.finfo, spec1, sizeof(c1.finfo)); spec1 += sizeof(c1.finfo); memcpy(&c2.finfo, spec2, sizeof(c2.finfo)); -- 2.39.2