Fix ext2 symlink bug.

rip->i_size is a target length without trailing '\0'.

Reported by Ben Gras.
This commit is contained in:
Evgeniy Ivanov 2011-08-29 23:36:48 +04:00 committed by Ben Gras
parent 7f24c2b3ca
commit 4806f7c308
2 changed files with 3 additions and 3 deletions

View File

@ -195,7 +195,7 @@ PUBLIC int fs_rdlink()
if( (rip = get_inode(fs_dev, (ino_t) fs_m_in.REQ_INODE_NR)) == NULL) if( (rip = get_inode(fs_dev, (ino_t) fs_m_in.REQ_INODE_NR)) == NULL)
return(EINVAL); return(EINVAL);
if (rip->i_size > MAX_FAST_SYMLINK_LENGTH) { if (rip->i_size >= MAX_FAST_SYMLINK_LENGTH) {
/* normal symlink */ /* normal symlink */
if ((b = read_map(rip, (off_t) 0)) == NO_BLOCK) { if ((b = read_map(rip, (off_t) 0)) == NO_BLOCK) {
r = EIO; r = EIO;

View File

@ -305,7 +305,7 @@ char *suffix; /* current remaining path. Has to point in the
llen = (size_t) rip->i_size; llen = (size_t) rip->i_size;
if (llen > MAX_FAST_SYMLINK_LENGTH) { if (llen >= MAX_FAST_SYMLINK_LENGTH) {
/* normal symlink */ /* normal symlink */
if ((blink = read_map(rip, (off_t) 0)) == NO_BLOCK) if ((blink = read_map(rip, (off_t) 0)) == NO_BLOCK)
return(EIO); return(EIO);
@ -358,7 +358,7 @@ char *suffix; /* current remaining path. Has to point in the
/* Everything is set, now copy the expanded link to user_path */ /* Everything is set, now copy the expanded link to user_path */
memmove(user_path, sp, llen); memmove(user_path, sp, llen);
if (llen > MAX_FAST_SYMLINK_LENGTH) if (llen >= MAX_FAST_SYMLINK_LENGTH)
put_block(bp, DIRECTORY_BLOCK); put_block(bp, DIRECTORY_BLOCK);
return(OK); return(OK);