Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed the second bug in #4, with ENAMETOOLONG

  • Loading branch information...
commit 056e918ed126a214f4530d986412932f48c3fd29 1 parent bd8bef4
fleuria authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/kern/sys2.c
14 src/kern/sys2.c
View
@@ -27,11 +27,16 @@ int sys_access(struct trap *tf){
struct inode *ip;
int r;
- if (vm_verify(path, strlen(path)+1) < 0) {
+ if (vm_verify(path, MAX_PATHSIZ) < 0) {
syserr(EFAULT);
return -1;
}
+ if (strnlen(path, MAX_PATHSIZ) == MAX_PATHSIZ) {
+ syserr(ENAMETOOLONG);
+ return -1;
+ }
+
ip = namei(path, 0);
if (ip==NULL) {
syserr(ENOENT);
@@ -46,11 +51,16 @@ int sys_open(struct trap *tf){
int mode = tf->edx;
int r;
- if (vm_verify(path, strlen(path)+1) < 0) {
+ if (vm_verify(path, MAX_PATHSIZ) < 0) {
syserr(EFAULT);
return -1;
}
+ if (strnlen(path, MAX_PATHSIZ) == MAX_PATHSIZ) {
+ syserr(ENAMETOOLONG);
+ return -1;
+ }
+
return do_open(path, flag, mode);
}
Please sign in to comment.
Something went wrong with that request. Please try again.