From 5ebbec4eeae9c8e79723890f3e5b9eb54aaa4739 Mon Sep 17 00:00:00 2001 From: didg Date: Mon, 12 May 2003 14:27:15 +0000 Subject: [PATCH] backport from head --- etc/afpd/catsearch.c | 38 ++++++++++++++++++-------------------- etc/afpd/directory.c | 4 ++-- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/etc/afpd/catsearch.c b/etc/afpd/catsearch.c index 6432ed5b..a908e135 100644 --- a/etc/afpd/catsearch.c +++ b/etc/afpd/catsearch.c @@ -257,7 +257,7 @@ static struct adouble *adl_lkup(struct path *path) adp = &ad; } - if ( ad_open( path->u_name, ADFLAGS_HF | (isdir)?ADFLAGS_DIR:0, O_RDONLY, 0, adp) < 0 ) { + if ( ad_open( path->u_name, ADFLAGS_HF | ((isdir)?ADFLAGS_DIR:0), O_RDONLY, 0, adp) < 0 ) { return NULL; } return adp; @@ -684,6 +684,7 @@ int catsearch_afp(AFPObj *obj, char *ibuf, int ibuflen, { struct vol *vol; u_int16_t vid; + u_int16_t spec_len; u_int32_t rmatches, reserved; u_int32_t catpos[4]; u_int32_t pdid = 0; @@ -729,32 +730,29 @@ int catsearch_afp(AFPObj *obj, char *ibuf, int ibuflen, return AFPERR_BITMAP; } - if ( ext) - ibuf++; + if ( ext) { + memcpy(&spec_len, ibuf, sizeof(spec_len)); + spec_len = ntohs(spec_len); + } + else { + spec_len = *(unsigned char*)ibuf; + } /* Parse file specifications */ spec1 = ibuf; - spec2 = ibuf + ibuf[0] + 2; - - if (ext) - { - spec1++; bspec1 = spec1; - spec2++; bspec2 = spec2; - } - else - { - spec1 += 2; bspec1 = spec1; - spec2 += 2; bspec2 = spec2; - } + spec2 = ibuf + spec_len + 2; + + spec1 += 2; + spec2 += 2; + bspec1 = spec1; + bspec2 = spec2; /* 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); } /* Parent DID */ @@ -797,7 +795,7 @@ int catsearch_afp(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)); diff --git a/etc/afpd/directory.c b/etc/afpd/directory.c index 9bb90287..bad91d45 100644 --- a/etc/afpd/directory.c +++ b/etc/afpd/directory.c @@ -1,5 +1,5 @@ /* - * $Id: directory.c,v 1.71.2.1 2003-05-10 10:33:16 didg Exp $ + * $Id: directory.c,v 1.71.2.2 2003-05-12 14:27:15 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -156,7 +156,7 @@ struct dir *dir; if ( strcmp( dir->d_u_name, name ) == 0 ) { break; } - dir = (dir == curdir->d_child->d_prev) ? NULL : dir->d_next; + dir = (dir == cdir->d_child->d_prev) ? NULL : dir->d_next; } return dir; } -- 2.39.2