On 12/09/2021 19:14, Pádraig Brady wrote: > +/* Return the corresponding Algorithm for the string S, > + or -1 for no match. */ > + > +static ptrdiff_t > +algorithm_from_tag (char *s) > +{ > + /* Limit check size to this length for perf reasons. */ > + static size_t max_tag_len; > + if (! max_tag_len) > + { > + char const * const * tag = algorithm_tags; > + while (*tag) > + { > + size_t tag_len = strlen (*tag++); > + max_tag_len = MAX (tag_len, max_tag_len); > + } > + } > + > + size_t i = 0; > + > + /* Find end of tag */ > + while (i < max_tag_len && s[i] && ! ISWHITE (s[i]) > + && s[i] != '-' && s[i] != '(') > + ++i; > + > + if (i > max_tag_len) > + return -1;
Oops. Off by one: diff --git a/src/digest.c b/src/digest.c index 3931c8ae8..9e1182005 100644 --- a/src/digest.c +++ b/src/digest.c @@ -653,7 +653,7 @@ algorithm_from_tag (char *s) size_t i = 0; /* Find end of tag */ - while (i < max_tag_len && s[i] && ! ISWHITE (s[i]) + while (i <= max_tag_len && s[i] && ! ISWHITE (s[i]) && s[i] != '-' && s[i] != '(') ++i;