From: Alan T. DeKok Date: Thu, 17 Dec 2020 21:07:24 +0000 (-0500) Subject: fr_sbuff_is_terminal() returns true on !tt && EOF X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b4ee089f8bfcd83e70a84ab822b47610e06b9a9;p=thirdparty%2Ffreeradius-server.git fr_sbuff_is_terminal() returns true on !tt && EOF --- diff --git a/src/lib/util/sbuff.c b/src/lib/util/sbuff.c index f0a8e56b3a4..915ed916717 100644 --- a/src/lib/util/sbuff.c +++ b/src/lib/util/sbuff.c @@ -1935,7 +1935,19 @@ bool fr_sbuff_is_terminal(fr_sbuff_t *in, fr_sbuff_term_t const *tt) uint8_t idx[UINT8_MAX + 1]; /* Fast path index */ size_t needle_len = 1; - if (!tt) return false; + /* + * No terminal, check for EOF. + */ + if (!tt) { + fr_sbuff_extend_status_t status = FR_SBUFF_EXTENDABLE; + + if ((fr_sbuff_extend_lowat(&status, in, 1) == 0) && + (status & FR_SBUFF_EXTEND_ERROR) == 0) { + return true; + } + + return false; + } /* * Initialise the fastpath index and