shithub: riscv

Download patch

ref: 72a840b31dd2ffc600dcffec7170eef76d7bb5ee
parent: 2f076f946fe7a5409cda7d83af5585442b294ec8
author: Ori Bernstein <[email protected]>
date: Mon Sep 24 21:02:31 EDT 2018

Disallow '/' in file names.

	A bad rename call could send a path with a '/' to cwfs.
	This is invalid, and should be disallowed.

--- a/sys/src/cmd/cwfs/sub.c
+++ b/sys/src/cmd/cwfs/sub.c
@@ -540,8 +540,8 @@
 /*
  * what are legal characters in a name?
  * only disallow control characters.
- * a) utf avoids control characters.
- * b) '/' may not be the separator
+ * utf avoids control characters, so we
+ * only need to inspect the ascii range.
  */
 int
 checkname(char *n)
@@ -556,7 +556,7 @@
 		c = n[i] & 0xff;
 		if(c == 0)
 			return 0;
-		if(c < 040)
+		if(c < 040 || c == '/')
 			return Ename;
 	}
 	return Etoolong;