server: anchor dsml_attr attribute match to a name boundary - #757
Open
Flor1an-B wants to merge 1 commit into
Open
server: anchor dsml_attr attribute match to a name boundary#757Flor1an-B wants to merge 1 commit into
Flor1an-B wants to merge 1 commit into
Conversation
dsml_attr() located an attribute with an unanchored strstr(tag, "name=\""), so an earlier attribute whose name ends in the sought name followed by =" shadowed the real one: on `<...invoke fullname="wrong" name="right">`, dsml_attr(tag, "name") returned "wrong", and on `<...invoke fullname="x">` it returned "x" for a "name" that is absent. The generated-DSML tool-call parser feeds whole invoke/parameter tags through this helper, so a drifted model tag with an extra attribute could yield the wrong tool name or argument value. (The server's own renderer emits fixed single attributes in a fixed order, so round-tripping its output is unaffected.) Match only at an attribute boundary (start of tag, or after whitespace), and guard the snprintf pattern against truncation. Test: --server (test_dsml_attr_anchors_attribute_name); it fails on the old helper (returns "wrong"/"x") and passes after the fix. Built -Wall -Wextra, 0 warnings, on Apple M5 Max. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
dsml_attr()locates an attribute with an unanchoredstrstr(tag, "name=\"").An earlier attribute whose name ends in the sought name followed by
="shadowsthe real one:
<|DSML|invoke fullname="wrong" name="right">→dsml_attr(tag, "name")returns"wrong".<|DSML|invoke fullname="x">→dsml_attr(tag, "name")returns"x"for anamethat is absent.The generated-DSML tool-call parser (
parse_deepseek_generated_message_ex) feedswhole
invoke/parametertags through this helper, so a drifted model tagcarrying an extra attribute could yield the wrong tool name or argument value.
Low severity: the server's own renderer emits fixed single attributes in a fixed
order, so round-tripping its output is unaffected — the bug needs a model tag
that puts a colliding attribute before
name/string. It is still a realcorrectness defect in the helper.
Fix
Match only at an attribute boundary (start of tag, or after whitespace), and
guard the
snprintfpattern against truncation.Test
--servergainstest_dsml_attr_anchors_attribute_name. It fails on the oldhelper (returns
"wrong"/"x", two assertions) and passes after the fix.Built
-Wall -Wextra, 0 warnings, Apple M5 Max.🤖 Generated with Claude Code