bfs_read_stat() now correctly reports the size of a link for symbolic links
that are short enough to be placed in the short symlink region. bfs_read_link() now makes sure that the link read is always null terminated. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9650 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4c6085f68c
commit
755901d835
@ -640,6 +640,11 @@ bfs_read_stat(void *_ns, void *_node, struct stat *st)
|
||||
st->st_uid = node->UserID();
|
||||
st->st_gid = node->GroupID();
|
||||
st->st_mode = node->Mode();
|
||||
|
||||
if (inode->IsSymLink() && (node->Flags() & INODE_LONG_SYMLINK) == 0) {
|
||||
// symlinks report the size of the link here
|
||||
st->st_size = strlen(node->short_symlink) + 1;
|
||||
} else
|
||||
st->st_size = node->data.Size();
|
||||
|
||||
st->st_atime = time(NULL);
|
||||
@ -1323,13 +1328,15 @@ bfs_read_link(void *_ns, void *_node, char *buffer, size_t bufferSize)
|
||||
RETURN_ERROR(B_BAD_VALUE);
|
||||
|
||||
if (inode->Flags() & INODE_LONG_SYMLINK) {
|
||||
if (inode->Size() > bufferSize)
|
||||
// we also need space for the terminating null byte
|
||||
if (inode->Size() >= bufferSize)
|
||||
return B_BUFFER_OVERFLOW;
|
||||
|
||||
status_t status = inode->ReadAt(0, (uint8 *)buffer, &bufferSize);
|
||||
if (status < B_OK)
|
||||
RETURN_ERROR(status);
|
||||
|
||||
buffer[bufferSize] = '\0';
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user