The buffer size should be at least "2 * sizeof(struct dirent)".
Otherwise, the code that checks dentry '..' overflow.
Fixes: http://tracker.ceph.com/issues/18941
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit
fa6671345b8f3a82dcd232f99e55a982b0a641f1)
// test getdents
struct dirent *getdents_entries;
- getdents_entries = (struct dirent *)malloc(r * sizeof(*getdents_entries));
+ getdents_entries = (struct dirent *)malloc((r + 2) * sizeof(*getdents_entries));
int count = 0;
std::vector<std::string> found;