add symlink follow counter
This commit is contained in:
parent
1dbdbd20d3
commit
049405989b
4
config.h
4
config.h
|
@ -26,8 +26,8 @@
|
||||||
#define FS_MAX_PATH_LEN 512
|
#define FS_MAX_PATH_LEN 512
|
||||||
#define FS_MAX_OPEN_FD 32
|
#define FS_MAX_OPEN_FD 32
|
||||||
#define FS_MAX_FNAME_LEN 11
|
#define FS_MAX_FNAME_LEN 11
|
||||||
#define FS_MAX_DIRECTORY_DEPTH 512
|
#define FS_MAX_DIRECTORY_DEPTH 2048
|
||||||
#define FS_MAX_SYMLINK_FOLLOWING_DEPTH 1024
|
#define FS_MAX_SYMLINK_FOLLOWS 1024
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
18
src/fs.c
18
src/fs.c
|
@ -935,6 +935,8 @@ static void resolve_path(struct resolved_path * const rp, const char * const ori
|
||||||
int current_inode_ptr;
|
int current_inode_ptr;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
unsigned int symlinks_followed = 0;
|
||||||
|
|
||||||
if (path[0] == '/') {
|
if (path[0] == '/') {
|
||||||
current_inode_ptr = 0;
|
current_inode_ptr = 0;
|
||||||
rp->parent_inode_ptr = 0;
|
rp->parent_inode_ptr = 0;
|
||||||
|
@ -978,6 +980,14 @@ static void resolve_path(struct resolved_path * const rp, const char * const ori
|
||||||
|
|
||||||
if (d.ftype == SYMLINK) {
|
if (d.ftype == SYMLINK) {
|
||||||
if (i+1 < path_len) {
|
if (i+1 < path_len) {
|
||||||
|
symlinks_followed++;
|
||||||
|
if (symlinks_followed > FS_MAX_SYMLINK_FOLLOWS) {
|
||||||
|
pr_err("too many symlink follows\n");
|
||||||
|
rp->parent_inode_ptr = -1;
|
||||||
|
rp->target_inode_ptr = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
char symlink_path[FS_MAX_PATH_LEN+1];
|
char symlink_path[FS_MAX_PATH_LEN+1];
|
||||||
int symlink_path_len = read_symlink(res, symlink_path);
|
int symlink_path_len = read_symlink(res, symlink_path);
|
||||||
|
|
||||||
|
@ -1017,6 +1027,14 @@ static void resolve_path(struct resolved_path * const rp, const char * const ori
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
symlinks_followed++;
|
||||||
|
if (symlinks_followed > FS_MAX_SYMLINK_FOLLOWS) {
|
||||||
|
pr_err("too many symlink follows\n");
|
||||||
|
rp->parent_inode_ptr = -1;
|
||||||
|
rp->target_inode_ptr = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
char symlink_path[FS_MAX_PATH_LEN+1];
|
char symlink_path[FS_MAX_PATH_LEN+1];
|
||||||
int symlink_path_len = read_symlink(res, symlink_path);
|
int symlink_path_len = read_symlink(res, symlink_path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue