]> arthur.barton.de Git - netatalk.git/commitdiff
Back-port from HEAD: Trailing and leading white spaces disallowed on
authorsrittau <srittau>
Mon, 14 Jan 2002 02:50:34 +0000 (02:50 +0000)
committersrittau <srittau>
Mon, 14 Jan 2002 02:50:34 +0000 (02:50 +0000)
AFPVOL_MSWINDOWS volumes.

NEWS
etc/afpd/directory.c
etc/afpd/file.c
etc/afpd/filedir.c
etc/afpd/volume.c
etc/afpd/volume.h

diff --git a/NEWS b/NEWS
index 1d363854f0c472b97ff4210bd75eaefcd73a32fd..6b189f8557c74b720264772fd41893f8e418dd92 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ Changes from 1.5.0
 * FIX: Really fix Tru64 compilation (see last entry).
 * FIX: Hand correct error value back to AFP client when deleting files or
        directories fails.
+* FIX: Leading or trailing spaces are now forbidden on volumes that have
+       the AFPVOL_MSWINDOWS flag set.
 * FIX: Minor code cleanups and warning fixes.
 * FIX: Make quota support work on FreeBSD.
 
index 96e708b7b1c0ab2f10ed88c50a7087c4fb319392..de8b95d79e3d0d2b638b039454226a5bd111839d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.19.2.2 2002-01-02 17:21:39 srittau Exp $
+ * $Id: directory.c,v 1.19.2.3 2002-01-14 02:50:34 srittau Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1425,8 +1425,7 @@ int               ibuflen, *rbuflen;
     }
 
     /* check for illegal bits */
-    if ((vol->v_flags & AFPVOL_MSWINDOWS) &&
-            strpbrk(path, MSWINDOWS_BADCHARS))
+    if (!wincheck(vol, path))
         return AFPERR_PARAM;
 
     upath = mtoupath(vol, path);
index b37e781cab45fed0160d5466ee93289900f4b341..c644da03d4944b02a6ac45076ee7dd9a265363cc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.c,v 1.29.2.2 2002-01-02 17:23:56 srittau Exp $
+ * $Id: file.c,v 1.29.2.3 2002-01-14 02:50:34 srittau Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -409,8 +409,7 @@ int         ibuflen, *rbuflen;
         return( AFPERR_NOOBJ );
     }
 
-    if ((vol->v_flags & AFPVOL_MSWINDOWS) &&
-            strpbrk(path, MSWINDOWS_BADCHARS))
+    if (!wincheck(vol, path))
         return AFPERR_PARAM;
 
     upath = mtoupath(vol, path);
index b8204d0b27e00e2ed31ab7e782f180b9c6884de6..29e0a3eafa8590a787a2f6eefdad4cc4b2882a79 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.15.2.1 2001-12-03 05:01:04 jmarcus Exp $
+ * $Id: filedir.c,v 1.15.2.2 2002-01-14 02:50:34 srittau Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -379,8 +379,7 @@ int         ibuflen, *rbuflen;
         return AFP_OK;
 
     /* check for illegal characters */
-    if ((vol->v_flags & AFPVOL_MSWINDOWS) &&
-            strpbrk(ibuf, MSWINDOWS_BADCHARS))
+    if (!wincheck(vol, ibuf))
         return AFPERR_PARAM;
 
     newpath = obj->oldtmp;
@@ -674,8 +673,7 @@ int         ibuflen, *rbuflen;
     }
 
     /* check for illegal characters */
-    if ((vol->v_flags & AFPVOL_MSWINDOWS) &&
-            strpbrk(newname, MSWINDOWS_BADCHARS))
+    if (!wincheck(vol, ibuf))
         return AFPERR_PARAM;
 
     upath = mtoupath(vol, newname);
index cce2f999c68742d2358f7f165d24a325aa5e5c3a..bb706d63ec3e33f913a49b82165b23f6bb904bd9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.14.2.1 2001-12-03 05:01:04 jmarcus Exp $
+ * $Id: volume.c,v 1.14.2.2 2002-01-14 02:50:34 srittau Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1395,3 +1395,27 @@ int              ibuflen, *rbuflen;
     ad_close(&ad, ADFLAGS_HF);
     return( AFP_OK );
 }
+
+
+int wincheck(struct vol *vol, const char *path)
+{
+       int len;
+
+       if (!(vol->v_flags & AFPVOL_MSWINDOWS))
+               return 1;
+
+       /* empty paths are not allowed */
+       if ((len = strlen(path)) == 0)
+               return 0;
+
+       /* leading or trailing whitespaces are not allowed */
+       if ((*path == ' ') || (path[len-1] == ' '))
+               return 0;
+
+       /* certain characters are not allowed */
+       if (strpbrk(path, MSWINDOWS_BADCHARS))
+               return 0;
+
+       /* everything else is okay */
+       return 1;
+}
index 61b59ec2ba3e92ac95809ca7ebae8239f437bb3c..0b8107520b2b38097767ac171c51efd8dae7cab4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.h,v 1.7.2.1 2001-12-03 05:01:04 jmarcus Exp $
+ * $Id: volume.h,v 1.7.2.2 2002-01-14 02:50:34 srittau Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -105,6 +105,8 @@ this is going away. */
 #define MSWINDOWS_BADCHARS "\\/<>*?|\""
 #define MSWINDOWS_CODEPAGE "maccode.iso8859-1"
 
+int wincheck(struct vol *vol, const char *path);
+
 #define AFPVOLSIG_FLAT          0x0001 /* flat fs */
 #define AFPVOLSIG_FIX          0x0002 /* fixed ids */
 #define AFPVOLSIG_VAR           0x0003 /* variable ids */