Archived
1
0
Fork 0

inotify-map.c: return a copy of a path list in lookup functions.

Becouse it is possible to change the a list stored by the API while traversing it, a bug can couse a infinite loop.
lets be strict about this and only return a copy of the list, so it can't be changed by calls to the API.
This commit is contained in:
Henrik Hautakoski 2011-01-30 15:55:51 +01:00
parent 33ceeca315
commit 440e5ed7d2
4 changed files with 22 additions and 17 deletions

View file

@ -22,18 +22,23 @@ static void teardown() {
inotify_unmap_all();
}
static void validate_list(int refindex, const struct str_list *l) {
static void validate_list(int index, char **list) {
int i;
assert(l);
assert(list);
for(i=0; i < 4; i++) {
if (i != wdref[refindex])
char **path, found = 0;
if (i != wdref[index])
continue;
assert(str_list_has(l, pathref[refindex]));
for(path=list; !found && *path; path++) {
if (!strcmp(*path, pathref[index]))
found = 1;
}
assert(found);
}
}