소스 검색

- fix use after free (Kevin Day)
dl_cleanup will call do_dlclose with the handle.
Inside of do_dlclose, the handle will ultimately get free'd.

Bernhard Reutner-Fischer 17 년 전
부모
커밋
ea7af1aad7
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      ldso/libdl/libdl.c

+ 5 - 3
ldso/libdl/libdl.c

@@ -146,9 +146,11 @@ static const char *dl_error_names[] = {
 void dl_cleanup(void) __attribute__ ((destructor));
 void dl_cleanup(void)
 {
-	struct dyn_elf *d;
-	for (d = _dl_handles; d; d = d->next_handle) {
-		do_dlclose(d, 1);
+	struct dyn_elf *h, *n;
+
+	for (h = _dl_handles; h; h = n) {
+		n = h->next_handle;
+		do_dlclose(h, 1);
 	}
 }