Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ByteQuadsCanonicalizer.addName(String, int, int) has incorrect handling for case of q2 == null #687

Closed
cowtowncoder opened this issue Mar 20, 2021 · 0 comments

Comments

@cowtowncoder
Copy link
Member

Up to Jackson 2.12.2, SymbolTable has:

    public String addName(String name, int q1, int q2) {
        _verifySharing();
        if (_intern) {
            name = InternCache.instance.intern(name);
        }
        int hash = (q2 == 0) ? calcHash(q1) : calcHash(q1, q2);
        ...
}

in which special handling is used if second "quad" is all zeroes. Presumable at some point calls were expected to be made with just q1 defined, q2 empty; and assumption probably being that this should for some reason also be supported just as an alias.

But it seems that doing this can be problematic if names (ids) with zero bytes are allowed: whether they are or not is debatable, but binary format like CBOR and Smile can technically encode such sequences. If so, there's a mismatch between "findName()" and "addName()" methods.

There also does not seem to be any good reason to have this check; plus removing it is a (small, granted) performance improvement.

So let's remove it from 2.13.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant