Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 553b1176 authored by Ken Chen's avatar Ken Chen
Browse files

Check if 'cache' is a valid pointer before dereference it

Null pointer dereference occurs when
step1: thread#1 is waiting for DNS response from server.
step2: thread#2 is querying on the same hostname, which release
       lock and enter waiting state.
step3: network disconnect.

Bug: b/124776120
Test: runtests.sh pass
Change-Id: I3ef1a2f06c4fd547fa3da4eed1a9152c3c55e704
parent 6d2c8928
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1502,6 +1502,9 @@ ResolvCacheStatus _resolv_cache_lookup(unsigned netid, const void* query, int qu
                                       cache = find_named_cache_locked(netid);
                                       return !cache_has_pending_request_locked(cache, &key, false);
                                   });
            if (!cache) {
                return RESOLV_CACHE_NOTFOUND;
            }
            if (ret == false) {
                resolv_cache_info* info = find_cache_info_locked(netid);
                if (info != NULL) {