diff options
Diffstat (limited to 'fs/devpts')
-rw-r--r-- | fs/devpts/root.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/fs/devpts/root.c b/fs/devpts/root.c index 04215ad40..f517367b9 100644 --- a/fs/devpts/root.c +++ b/fs/devpts/root.c @@ -134,7 +134,8 @@ static int devpts_revalidate(struct dentry * dentry) static int devpts_root_lookup(struct inode * dir, struct dentry * dentry) { struct devpts_sb_info *sbi = SBI(dir->i_sb); - int entry, i; + unsigned int entry; + int i; const char *p; if (!S_ISDIR(dir->i_mode)) @@ -154,17 +155,23 @@ static int devpts_root_lookup(struct inode * dir, struct dentry * dentry) entry = *p++ - '0'; for ( i = dentry->d_name.len-1 ; i ; i-- ) { - if ( *p < '0' || *p > '9' ) + unsigned int nentry = *p++ - '0'; + if ( nentry > 9 ) return 0; - entry *= 10; - entry += (*p++ - '0'); + nentry += entry * 10; + if (nentry < entry) + return 0; + entry = nentry; } } - + + if ( entry >= sbi->max_ptys ) + return 0; + dentry->d_inode = sbi->inodes[entry]; if ( dentry->d_inode ) dentry->d_inode->i_count++; - + d_add(dentry, dentry->d_inode); return 0; |