]> git.puffer.fish Git - matthieu/frr.git/commit
lib: fix c-ares thread misuse
authorDavid Lamparter <equinox@opensourcerouting.org>
Sun, 7 Nov 2021 14:41:18 +0000 (15:41 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Mon, 8 Nov 2021 13:06:21 +0000 (14:06 +0100)
commitfaf079ff7e835bd454dda0804e677c477489b3ed
treed0db963ebb2ab1837af10e2d999fd01f2e808af9
parent2d5b7a5b46272de149c93dc70778bce19e67b01d
lib: fix c-ares thread misuse

The `struct thread **ref` that the thread code takes is written to and
needs to stay valid over the lifetime of a thread.  This does not hold
up if thread pointers are directly put in a `vector` since adding items
to a `vector` may reallocate the entire array.  The thread code would
then write to a now-invalid `ref`, potentially corrupting entirely
unrelated data.

This should be extremely rare to trigger in practice since we only use
one c-ares channel, which will likely only ever use one fd, so the
vector is never resized.  That said, c-ares using only one fd is just
plain fragile luck.

Either way, fix this by creating a resolver_fd tracking struct, and
clean up the code while we're at it.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/resolver.c