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:
parent
33ceeca315
commit
440e5ed7d2
4 changed files with 22 additions and 17 deletions
|
|
@ -148,13 +148,13 @@ int inotify_map_get_wd(const char *path) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
const struct str_list* inotify_map_lookup(int wd) {
|
||||
|
||||
char** inotify_map_lookup(int wd) {
|
||||
|
||||
struct map_wd *m = rbtree_search(&tree_wd_paths, &wd);
|
||||
return m ? &m->paths : NULL;
|
||||
return m ? str_list_export(&m->paths) : NULL;
|
||||
}
|
||||
|
||||
const struct str_list* inotify_map_lookup_by_path(const char *path) {
|
||||
char** inotify_map_lookup_by_path(const char *path) {
|
||||
|
||||
struct map_path *p = rbtree_search(&tree_path_wd, &path);
|
||||
return p ? inotify_map_lookup(p->wd) : NULL;
|
||||
|
|
|
|||
Reference in a new issue