java icon indicating copy to clipboard operation
java copied to clipboard

Null parsing accepts bad input

Open mtdowling opened this issue 2 months ago • 4 comments

Various places in this library that parse null will see 'n' and then skip the next three characters without validating that the next three characters are 'u' 'l' 'l'. So this is parsed as null: nope.

See for example https://github.com/json-iterator/java/blob/master/src/main/java/com/jsoniter/IterImplObject.java#L10-L12

    public static final String readObject(JsonIterator iter) throws IOException {
        byte c = IterImpl.nextToken(iter);
        switch (c) {
            case 'n':
                IterImpl.skipFixedBytes(iter, 3);
                return null;

mtdowling avatar Jun 27 '24 18:06 mtdowling