From: Charles Manning Date: Tue, 30 Nov 2010 23:37:16 +0000 (+1300) Subject: yaffs direct: Add more tests for valid paths. X-Git-Tag: linux-mainline-patchset-4~19 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=f6a8cdab85cba8cfba3d6c44b99957e4e299670b yaffs direct: Add more tests for valid paths. Signed-off-by: Charles Manning --- diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index d6fd40e..2b1a82c 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -1397,7 +1397,8 @@ int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath) return -1; } - if(yaffsfs_CheckPath(newPath) < 0){ + if(yaffsfs_CheckPath(oldPath) < 0 || + yaffsfs_CheckPath(newPath) < 0){ yaffsfs_SetError(-ENAMETOOLONG); return -1; } @@ -2489,6 +2490,11 @@ loff_t yaffs_totalspace(const YCHAR *path) struct yaffs_dev *dev=NULL; YCHAR *dummy; + if(!path){ + yaffsfs_SetError(-EFAULT); + return -1; + } + if(yaffsfs_CheckPath(path) < 0){ yaffsfs_SetError(-ENAMETOOLONG); return -1; @@ -2786,10 +2792,12 @@ int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath) return -1; } - if(yaffsfs_CheckPath(newpath) < 0){ + if(yaffsfs_CheckPath(newpath) < 0 || + yaffsfs_CheckPath(oldpath) < 0){ yaffsfs_SetError(-ENAMETOOLONG); return -1; } + yaffsfs_Lock(); parent = yaffsfs_FindDirectory(NULL,newpath,&name,0,¬Dir,&loop); if(!parent && notDir) @@ -2870,7 +2878,8 @@ int yaffs_link(const YCHAR *oldpath, const YCHAR *linkpath) return -1; } - if(yaffsfs_CheckPath(linkpath) < 0){ + if(yaffsfs_CheckPath(linkpath) < 0 || + yaffsfs_CheckPath(oldpath) < 0){ yaffsfs_SetError(-ENAMETOOLONG); return -1; }