* cdda_read_dir() could copy too many bytes into the provided buffer (worst

case was an unterminated string, though).
* fix_dirent() did not copy the trailing null-byte.
* Not yet entirely sure why, but this caused #4214.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32254 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-08-11 15:46:07 +00:00
parent 81147288e5
commit a068dcb15a
2 changed files with 12 additions and 11 deletions
@@ -1865,7 +1865,8 @@ cdda_read_dir(fs_volume* _volume, fs_vnode* _node, void* _cookie,
} }
if (user_memcpy(buffer, &entry, sizeof(struct dirent) - 1) != B_OK if (user_memcpy(buffer, &entry, sizeof(struct dirent) - 1) != B_OK
|| user_strlcpy(buffer->d_name, name, bufferSize) < B_OK) || user_strlcpy(buffer->d_name, name,
bufferSize + 1 - sizeof(struct dirent)) < B_OK)
return B_BAD_ADDRESS; return B_BAD_ADDRESS;
buffer = (struct dirent*)((uint8*)buffer + entry.d_reclen); buffer = (struct dirent*)((uint8*)buffer + entry.d_reclen);
+1 -1
View File
@@ -5564,7 +5564,7 @@ fix_dirent(struct vnode* parent, struct dirent* userEntry,
ASSERT(entry->d_reclen >= sizeof(struct dirent)); ASSERT(entry->d_reclen >= sizeof(struct dirent));
if (user_memcpy(entry->d_name, userEntry->d_name, if (user_memcpy(entry->d_name, userEntry->d_name,
entry->d_reclen - sizeof(struct dirent)) != B_OK) entry->d_reclen + 1 - sizeof(struct dirent)) != B_OK)
return B_BAD_ADDRESS; return B_BAD_ADDRESS;
} else } else
entry = userEntry; entry = userEntry;