From 41da5b7f4976dcd12dacdf983e1f32d5285ce927 Mon Sep 17 00:00:00 2001 From: srittau Date: Wed, 13 Mar 2002 19:29:14 +0000 Subject: [PATCH] Eddie's wincheck() fix. --- etc/afpd/directory.c | 10 +++++----- etc/afpd/file.c | 11 ++++++----- etc/afpd/file.h | 3 +-- etc/afpd/filedir.c | 18 +++++++++--------- etc/afpd/volume.c | 8 +++++--- etc/afpd/volume.h | 4 ++-- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/etc/afpd/directory.c b/etc/afpd/directory.c index 3ad6d1d4..f7a5351b 100644 --- a/etc/afpd/directory.c +++ b/etc/afpd/directory.c @@ -1,5 +1,5 @@ /* - * $Id: directory.c,v 1.26 2002-01-19 21:29:55 jmarcus Exp $ + * $Id: directory.c,v 1.27 2002-03-13 19:29:14 srittau Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -1424,12 +1424,12 @@ int ibuflen, *rbuflen; } } - /* check for illegal bits */ - if (!wincheck(vol, path)) - return AFPERR_PARAM; - upath = mtoupath(vol, path); + /* check for illegal bits in the unix filename */ + if (!wincheck(vol, upath)) + return AFPERR_PARAM; + if ((vol->v_flags & AFPVOL_NOHEX) && strchr(upath, '/')) return AFPERR_PARAM; diff --git a/etc/afpd/file.c b/etc/afpd/file.c index 0f3280fe..36d0046c 100644 --- a/etc/afpd/file.c +++ b/etc/afpd/file.c @@ -1,5 +1,5 @@ /* - * $Id: file.c,v 1.40 2002-03-05 02:04:46 jmarcus Exp $ + * $Id: file.c,v 1.41 2002-03-13 19:29:17 srittau Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -422,11 +422,12 @@ int ibuflen, *rbuflen; return( AFPERR_NOOBJ ); } - if (!wincheck(vol, path)) - return AFPERR_PARAM; - upath = mtoupath(vol, path); + /* check for illegal bits in the unix filename */ + if (!wincheck(vol, upath)) + return AFPERR_PARAM; + if ((vol->v_flags & AFPVOL_NOHEX) && strchr(upath, '/')) return AFPERR_PARAM; @@ -1727,7 +1728,7 @@ int ibuflen, *rbuflen; /* all this stuff is so that we can unwind a failed operation * properly. */ -err_temp_to_dest: + /* rename dest to temp */ renamefile(upath, temp, temp, vol_noadouble(vol)); of_rename(vol, curdir, upath, curdir, temp); diff --git a/etc/afpd/file.h b/etc/afpd/file.h index 477526de..a6af6bb8 100644 --- a/etc/afpd/file.h +++ b/etc/afpd/file.h @@ -1,5 +1,5 @@ /* - * $Id: file.h,v 1.4 2001-12-03 05:03:38 jmarcus Exp $ + * $Id: file.h,v 1.5 2002-03-13 19:29:17 srittau Exp $ * * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. @@ -71,7 +71,6 @@ struct extmap { char em_type[ 4 ]; }; -extern struct extmap *extmap; extern struct extmap *getextmap __P((const char *)); extern int getfilparams __P((struct vol *, u_int16_t, char *, diff --git a/etc/afpd/filedir.c b/etc/afpd/filedir.c index f47d5f7a..a50c33b7 100644 --- a/etc/afpd/filedir.c +++ b/etc/afpd/filedir.c @@ -1,5 +1,5 @@ /* - * $Id: filedir.c,v 1.23 2002-03-05 01:41:36 srittau Exp $ + * $Id: filedir.c,v 1.24 2002-03-13 19:29:17 srittau Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -378,13 +378,13 @@ int ibuflen, *rbuflen; if (strcmp(path, ibuf) == 0) return AFP_OK; - /* check for illegal characters */ - if (!wincheck(vol, ibuf)) - return AFPERR_PARAM; - newpath = obj->oldtmp; strcpy( newpath, mtoupath(vol, ibuf )); + /* check for illegal characters in the unix filename */ + if (!wincheck(vol, newpath)) + return AFPERR_PARAM; + if ((vol->v_flags & AFPVOL_NOHEX) && strchr(newpath, '/')) return AFPERR_PARAM; @@ -672,12 +672,12 @@ int ibuflen, *rbuflen; newname[ plen ] = '\0'; } - /* check for illegal characters */ - if (!wincheck(vol, newname)) - return AFPERR_PARAM; - upath = mtoupath(vol, newname); + /* check for illegal characters in the unix filename */ + if (!wincheck(vol, upath)) + return AFPERR_PARAM; + if ((vol->v_flags & AFPVOL_NOHEX) && strchr(upath, '/')) return AFPERR_PARAM; diff --git a/etc/afpd/volume.c b/etc/afpd/volume.c index 09b9841e..ddfc6186 100644 --- a/etc/afpd/volume.c +++ b/etc/afpd/volume.c @@ -1,5 +1,5 @@ /* - * $Id: volume.c,v 1.22 2002-02-06 21:58:50 jmarcus Exp $ + * $Id: volume.c,v 1.23 2002-03-13 19:29:17 srittau Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -1410,8 +1410,10 @@ int wincheck(struct vol *vol, const char *path) if ((len = strlen(path)) == 0) return 0; - /* leading or trailing whitespaces are not allowed */ - if ((*path == ' ') || (path[len-1] == ' ')) + /* leading or trailing whitespaces are not allowed, carriage returns + * and probably other whitespace is okay, tabs are not allowed + */ + if ((path[0] == ' ') || (path[len-1] == ' ')) return 0; /* certain characters are not allowed */ diff --git a/etc/afpd/volume.h b/etc/afpd/volume.h index eb78adac..fac777c2 100644 --- a/etc/afpd/volume.h +++ b/etc/afpd/volume.h @@ -1,5 +1,5 @@ /* - * $Id: volume.h,v 1.9 2002-01-02 21:14:10 srittau Exp $ + * $Id: volume.h,v 1.10 2002-03-13 19:29:17 srittau Exp $ * * Copyright (c) 1990,1994 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -102,7 +102,7 @@ this is going away. */ #define AFPVOL_UUPPERMLOWER (AFPVOL_MTOUUPPER | AFPVOL_UTOMLOWER) #define AFPVOL_ULOWERMUPPER (AFPVOL_MTOULOWER | AFPVOL_UTOMUPPER) -#define MSWINDOWS_BADCHARS "\\/<>*?|\"" +#define MSWINDOWS_BADCHARS ":\t\\/<>*?|\"" #define MSWINDOWS_CODEPAGE "maccode.iso8859-1" int wincheck(struct vol *vol, const char *path); -- 2.39.2