libapparmor: Fix segfault when loading policy cache files

qsort()'s _size_ parameter is used to indicate the size of the elements
in the _base_ array parameter. Adjust the third argument to qsort() to
indicate that we're dealing with an array of struct dirent pointers
rather than an array of struct dirent.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/348
(cherry picked from commit 8b21871820)
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
Tyler Hicks 2019-03-12 23:43:48 +00:00 committed by John Johansen
parent 68eb3be2ae
commit 01aec04bd6

View file

@ -366,7 +366,7 @@ static ssize_t readdirfd(int dirfd, struct dirent ***out,
}
if (dircmp)
qsort(dents, n, sizeof(*dent), (int (*)(const void *, const void *))dircmp);
qsort(dents, n, sizeof(struct dirent *), (int (*)(const void *, const void *))dircmp);
*out = dents;
closedir(dir);