/*
- * $Id: directory.c,v 1.45 2002-10-12 18:20:48 didg Exp $
+ * $Id: directory.c,v 1.46 2002-10-13 06:18:13 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
int len;
int olen = 0;
u_int32_t hint;
+ u_int16_t len16;
int size = 0;
char sep;
case 3:
if (afp_version >= 30) {
data++;
- hint = ntohl(*data);
- data += 4;
- len = ntohs(*data);
+ memcpy(&hint, data, sizeof(hint));
+ hint = ntohl(hint);
+ data += sizeof(hint);
+
+ memcpy(&len16, data, sizeof(len16));
+ len = ntohs(len16);
data += 2;
size = 7;
sep = '/';
return &ret;
}
- if ( *data == '\0' ) {
+ if (!*data || *data == sep ) {
data++;
len--;
}
}
memset(&ad, 0, sizeof(ad));
- if (ad_open( "", vol_noadouble(vol)|ADFLAGS_HF|ADFLAGS_DIR,
+ if (ad_open( ".", vol_noadouble(vol)|ADFLAGS_HF|ADFLAGS_DIR,
O_RDWR|O_CREAT, 0666, &ad ) < 0) {
if (vol_noadouble(vol))
goto createdir_done;
/*
- * $Id: file.c,v 1.64 2002-10-12 04:02:46 didg Exp $
+ * $Id: file.c,v 1.65 2002-10-13 06:18:13 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
case FILPBIT_PDINFO :
if (afp_version >= 30) { /* UTF8 name */
utf8 = kTextEncodingUTF8;
+ nameoff = data;
data += sizeof( u_int16_t );
}
else {
return( AFP_OK );
}
+int copy_path_name(char *newname, char *ibuf)
+{
+char type = *ibuf;
+size_t plen = 0;
+u_int16_t len16;
+u_int32_t hint;
+
+ if ( type != 2 || (afp_version >= 30 && type != 3) ) {
+ return -1;
+ }
+ ibuf++;
+ switch (type) {
+ case 2:
+ if (( plen = (unsigned char)*ibuf++ ) != 0 ) {
+ strncpy( newname, ibuf, plen );
+ newname[ plen ] = '\0';
+ if (strlen(newname) != plen) {
+ /* there's \0 in newname, e.g. it's a pathname not
+ * only a filename.
+ */
+ return -1;
+ }
+ }
+ break;
+ case 3:
+ memcpy(&hint, ibuf, sizeof(hint));
+ ibuf += sizeof(hint);
+
+ memcpy(&len16, ibuf, sizeof(len16));
+ ibuf += sizeof(len16);
+ plen = ntohs(len16);
+ if (plen) {
+ strncpy( newname, ibuf, plen );
+ newname[ plen ] = '\0';
+ if (strchr(newname,'/')) {
+ return -1;
+ }
+ }
+ break;
+ }
+ return plen;
+}
+
/* -----------------------------------
*/
int afp_copyfile(obj, ibuf, ibuflen, rbuf, rbuflen )
char *newname, *p, *upath;
struct path *s_path;
u_int32_t sdid, ddid;
- size_t plen;
int err, retvalue = AFP_OK;
u_int16_t svid, dvid;
}
/* one of the handful of places that knows about the path type */
- if ( *ibuf++ != 2 ) {
+ if (copy_path_name(newname, ibuf) < 0) {
return( AFPERR_PARAM );
}
- if (( plen = (unsigned char)*ibuf++ ) != 0 ) {
- strncpy( newname, ibuf, plen );
- newname[ plen ] = '\0';
- if (strlen(newname) != plen) {
- /* there's \0 in newname, e.g. it's a pathname not
- * only a filename.
- */
- return( AFPERR_PARAM );
- }
- }
+
upath = mtoupath(vol, newname);
if ( (err = copyfile(p, upath , newname, vol_noadouble(vol))) < 0 ) {
return err;
/*
- * $Id: file.h,v 1.13 2002-10-12 04:02:46 didg Exp $
+ * $Id: file.h,v 1.14 2002-10-13 06:18:13 didg Exp $
*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* All Rights Reserved.
#define FILPBIT_DFLEN 9
#define FILPBIT_RFLEN 10
#define FILPBIT_EXTDFLEN 11
-#define FILPBIT_PDINFO 13 /* ProDOS Info */
+#define FILPBIT_PDINFO 13 /* ProDOS Info/ UTF8 name */
#define FILPBIT_EXTRFLEN 14
/* attribute bits. (d) = directory attribute bit as well. */
extern int deletefile __P((char *, int));
extern void *get_finderinfo __P((const char *, struct adouble *, void *));
+extern int copy_path_name __P((char *, char *i));
/* FP functions */
extern int afp_exchangefiles __P((AFPObj *, char *, int, char *, int *));
/*
- * $Id: filedir.c,v 1.33 2002-10-11 14:18:31 didg Exp $
+ * $Id: filedir.c,v 1.34 2002-10-13 06:18:13 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
char *oldname, *newname;
struct path *path;
u_int32_t did;
- size_t plen;
+ int plen;
u_int16_t vid;
int isdir = 0;
int rc;
}
/* another place where we know about the path type */
- if ( *ibuf++ != 2 ) {
+ if ((plen = copy_path_name(newname, ibuf)) < 0) {
return( AFPERR_PARAM );
}
- if (( plen = (unsigned char)*ibuf++ ) != 0 ) {
- strncpy( newname, ibuf, plen );
- newname[ plen ] = '\0';
- if (strlen(newname) != plen) {
- return( AFPERR_PARAM );
- }
- }
- else {
+ if (!plen) {
return AFP_OK; /* newname == oldname same dir */
}
char *oldname, *newname;
struct path *path;
int did;
- size_t plen;
+ int plen;
u_int16_t vid;
int rc;
#ifdef DROPKLUDGE
}
/* one more place where we know about path type */
- if ( *ibuf++ != 2 ) {
+ if ((plen = copy_path_name(newname, ibuf)) < 0) {
return( AFPERR_PARAM );
}
- if (( plen = (unsigned char)*ibuf++ ) != 0 ) {
- strncpy( newname, ibuf, plen );
- newname[ plen ] = '\0';
- if (strlen(newname) != plen) {
- return( AFPERR_PARAM );
- }
- }
- else {
+ if (!plen) {
strcpy(newname, oldname);
}
-
+
rc = moveandrename(vol, sdir, oldname, newname, isdir);
if ( rc == AFP_OK ) {
/*
- * $Id: fork.c,v 1.38 2002-10-11 14:18:32 didg Exp $
+ * $Id: fork.c,v 1.39 2002-10-13 06:18:14 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
if (is64) {
temp = htonl(offset >> 32);
memcpy(rbuf, &temp, sizeof( temp ));
+ rbuf += sizeof(temp);
ret = sizeof( temp );
offset &= 0xffffffff;
}
return write_fork(obj, ibuf, ibuflen, rbuf, rbuflen, 0);
}
-/* ---------------------------- */
+/* ----------------------------
+ * FIXME need to deal with SIGXFSZ signal
+*/
int afp_write_ext(obj, ibuf, ibuflen, rbuf, rbuflen)
AFPObj *obj;
char *ibuf, *rbuf;
/*
- * $Id: uams_guest.c,v 1.10 2002-09-29 23:30:20 sibaz Exp $
+ * $Id: uams_guest.c,v 1.11 2002-10-13 06:18:14 didg Exp $
*
* (c) 2001 (see COPYING)
*/
#include "config.h"
#endif /* HAVE_CONFIG_H */
+#ifndef ATACC
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
UAM_MODULE_VERSION,
uam_setup, uam_cleanup
};
+#endif
/*
- * $Id: uams_pam.c,v 1.12 2002-09-29 23:30:20 sibaz Exp $
+ * $Id: uams_pam.c,v 1.13 2002-10-13 06:18:14 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* Copyright (c) 1999 Adrian Sun (asun@u.washington.edu)
#include "config.h"
#endif /* HAVE_CONFIG_H */
+#ifndef ATACC
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
UAM_MODULE_VERSION,
uam_setup, uam_cleanup
};
+#endif