/*
- * $Id: appl.c,v 1.13 2003-05-03 20:03:12 didg Exp $
+ * $Id: appl.c,v 1.16 2008-12-03 18:35:44 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif /* HAVE_FCNTL_H */
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-#include <sys/types.h>
-#include <sys/stat.h>
+
#include <sys/param.h>
#include <atalk/logger.h>
#include <errno.h>
-#include <netatalk/endian.h>
#include <atalk/adouble.h>
#include <atalk/afp.h>
#include "file.h"
#include "desktop.h"
-static struct savedt sa = { { 0, 0, 0, 0 }, -1, 0 };
+static struct savedt sa = { { 0, 0, 0, 0 }, -1, 0, 0};
-static __inline__ int pathcmp( p, plen, q, qlen )
+static int pathcmp( p, plen, q, qlen )
char *p;
int plen;
char *q;
static int applopen( vol, creator, flags, mode )
struct vol *vol;
u_char creator[ 4 ];
+int flags;
+int mode;
{
char *dtf, *adt, *adts;
* but uses upaths instead of mac format paths.
*
* The new way: dir and path refer to an app, path is a mac format
- * pathname. makemacpath() builds a cname.
+ * pathname. makemacpath() builds a cname. (zero is a path separator
+ * and it's not \0 terminated).
*
* See afp_getappl() for the backward compatiblity code.
*/
p = mpath + mpathlen;
p -= strlen( path );
- strncpy( p, path, strlen( path ));
+ memcpy( p, path, strlen( path ));
while ( dir->d_parent != NULL ) {
p -= strlen( dir->d_m_name ) + 1;
+ if (p < mpath) {
+ /* FIXME: pathname too long */
+ return NULL;
+ }
strcpy( p, dir->d_m_name );
dir = dir->d_parent;
}
int afp_addappl(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj *obj;
-char *ibuf, *rbuf;
-int ibuflen, *rbuflen;
+AFPObj *obj;
+char *ibuf, *rbuf _U_;
+int ibuflen _U_, *rbuflen;
{
struct vol *vol;
struct dir *dir;
}
mpath = obj->newtmp;
mp = makemacpath( mpath, AFPOBJ_TMPSIZ, curdir, path->m_name );
+ if (!mp) {
+ return AFPERR_PARAM;
+ }
mplen = mpath + AFPOBJ_TMPSIZ - mp;
/* write the new appl entry at start of temporary file */
}
int afp_rmvappl(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj *obj;
-char *ibuf, *rbuf;
-int ibuflen, *rbuflen;
+AFPObj *obj;
+char *ibuf, *rbuf _U_;
+int ibuflen _U_, *rbuflen;
{
struct vol *vol;
struct dir *dir;
}
mpath = obj->newtmp;
mp = makemacpath( mpath, AFPOBJ_TMPSIZ, curdir, path->m_name );
+ if (!mp) {
+ return AFPERR_PARAM ;
+ }
+
mplen = mpath + AFPOBJ_TMPSIZ - mp;
cc = copyapplfile( sa.sdt_fd, tfd, mp, mplen );
close( tfd );
}
int afp_getappl(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj *obj;
+AFPObj *obj;
char *ibuf, *rbuf;
-int ibuflen, *rbuflen;
+int ibuflen _U_, *rbuflen;
{
struct vol *vol;
char *p, *q;