From b218bfc2302ebb5f36870fffa84bf4ac8b5f63f8 Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 23 Sep 2026 21:21:57 +0000 Subject: [PATCH] Fix off-by-one in TCP Option vectorization Effect was potential mischaracterization of OS with 17 TCP options, due to option type of 17th overwriting the length of the 1st. --- FPEngine.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FPEngine.cc b/FPEngine.cc index d362c7325..438d560cb 100644 --- a/FPEngine.cc +++ b/FPEngine.cc @@ -847,6 +847,7 @@ struct tcpopt_vectorize_ctx { static const u8 MODEL_NUM_OPTS = 16; static bool tcpopt_vectorize(u8 op, u8 oplen, const u8 *data, void *ctx) { tcpopt_vectorize_ctx *c = static_cast(ctx); + assert(c->optnum < MODEL_NUM_OPTS); c->features[c->base + c->optnum].value = op; c->features[c->base + c->optnum + MODEL_NUM_OPTS].value = oplen; if (op == TCPOPT_MSS && oplen == 4 && c->mss == -1) @@ -855,9 +856,8 @@ static bool tcpopt_vectorize(u8 op, u8 oplen, const u8 *data, void *ctx) { c->sackok = 1; else if (op == TCPOPT_WSCALE && oplen == 3 && c->wscale == -1) c->wscale = data[2]; - if (c->optnum++ < MODEL_NUM_OPTS) - return true; - return false; + c->optnum++; + return c->optnum < MODEL_NUM_OPTS; } static struct feature_node *vectorize(const FingerPrintResultsIPv6 *FPR) {