Skip to content
Snippets Groups Projects
Commit 2b825a1a authored by Nick Mathewson's avatar Nick Mathewson :game_die:
Browse files

Fix a crash bug in max_u16_in_sl()

The documentation for this function says that the smartlist can
contain NULLs, but the code only handled NULLs if they were at the
start of the list.

We didn't notice this for a long time, because when Tor is run
normally, the sequence of msg_id_t is densely packed, and so this
list (mapping msg_id_t to channel_id_t) contains no NULL elements.
We could only run into this bug:
  * when Tor was running in embedded mode, and starting more than once.
  * when Tor ran first with more pubsub messages enabled, and then
    later with fewer.
  * When the second run (the one with fewer enabled pubsub messages)
    had at least some messages enabled, and those messages were not
    the ones with numerically highest msg_id_t values.

Fixes bug 31898; bugfix on 47de9c7b
in 0.4.1.1-alpha.
parent 34bbdaf5
No related branches found
No related tags found
No related merge requests found
o Major bugfixes (embedded Tor):
- Avoid a possible crash when restarting Tor in embedded mode and
enabling a different set of publish/subscribe messages. Fixes bug
31898; bugfix on 0.4.1.1-alpha.
......@@ -34,7 +34,7 @@ max_in_u16_sl(const smartlist_t *sl, int dflt)
SMARTLIST_FOREACH_BEGIN(sl, uint16_t *, u) {
if (!maxptr)
maxptr = u;
else if (*u > *maxptr)
else if (u && *u > *maxptr)
maxptr = u;
} SMARTLIST_FOREACH_END(u);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment