Fix UAF in LoginStateChecker and related browser tests This CL fixes a use-after-free in `LoginStateChecker` and a related off-by-one error in its browser tests. The first issue was in `RespondWithLoginStatus`, where a callback was run before incrementing a member variable. If the callback destroyed the instance, this led to a UAF. The fix is to increment the counter before invoking the callback. Re-enabling the browser tests revealed a second UAF. The tests were calling `RespondWithLoginStatus` `kMaxLoginChecks + 1` times due to an off-by-one error in a loop. Since the `LoginStateChecker` destroys itself after `kMaxLoginChecks` calls, the final call was on a dangling pointer. This CL also corrects the test loop. With both fixes, the following tests are now stable and re-enabled: - PasswordChangeDoesNotStartUserIsLoggedOut - OpenTabWhenLoggedOut - PasswordChangeStartsUserIsLoggedIn Bug: 441807493 Change-Id: Ieb91f2c24753e45577db4594b67043bf7cf09922 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6899063 Owners-Override: Yoshisato Yanagisawa <yyanagisawa@google.com> Reviewed-by: Kenichi Ishibashi <bashi@chromium.org> Commit-Queue: Yoshisato Yanagisawa <yyanagisawa@chromium.org> Reviewed-by: Viktor Semeniuk <vsemeniuk@google.com> Cr-Commit-Position: refs/heads/main@{#1508227}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure.
For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.
If you found a bug, please file it at https://crbug.com/new.