Skip to content

Find NPE in SqlRunner.java #2280

@containerAnalyzer

Description

@containerAnalyzer

Hello,
Our static analyzer found a following potential NPE. We have checked the feasibility of this execution trace. It is necessary to defend this vulnerability to improve the code quality.

  1. Select the true branch at this point (class.equals(class)!=0 is true)

    } else if (!handler.getClass().equals(soleHandler.getClass())) {

  2. Select the true branch at this point (jdbcHandlerMap.values().iterator().hasNext()==0 is true)

    for (TypeHandler<?> handler : jdbcHandlerMap.values()) {

  3. Return soleHandler to caller, which can be null (The return value can be null)

  4. Function pickSoleHandler executes and returns

    handler = pickSoleHandler(jdbcHandlerMap);

  5. Return handler to caller, which can be null (The return value can be null)

  6. Return the return value of function getTypeHandler to caller

    return getTypeHandler((Type) type, null);

  7. Function getTypeHandler executes and stores the return value to typehandler (typehandler can be null)

    typeHandler = typeHandlerRegistry.getTypeHandler(Object.class);

  8. Function add executes and typeHandlers contains null

    typeHandlers.add(typeHandler);

  9. Function get executes and stores the return value to handler (handler can be null)

    TypeHandler<?> handler = typeHandlers.get(i);

  10. handler is passed as the this pointer to function getResult (handler can be null), which will leak to null pointer dereference

    row.put(name.toUpperCase(Locale.ENGLISH), handler.getResult(rs, name));

Commit: b459c61

ContainerAnalyzer

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions