Skip to content

issue about null pointer dereference #15

@QiuYitai

Description

@QiuYitai

Hello,
Our team has recently been conducting research on a null-pointer-dereference (NPD) vulnerability detection tool and used it to scan smatch(the version on the master branch). After a manual review, we have identified some potentially vulnerable code snippets that may lead to null-pointer-dereference bugs.
The NULL Dereference vulnerability happens in struct expression *strip_expr_statement(), smatch_db.c
How the NULL Pointer Dereference happens:

  1. When the last_stmt is Null
  2. NULL dereference of variable last_stmt->label_statement happens at last_stmt = last_stmt->label_statement;
struct expression *strip_expr_statement(struct expression *expr)
{
    struct expression *orig = expr;
    struct statement *stmt, *last_stmt;
    ......
=>  last_stmt = last_ptr_list((struct ptr_list *)stmt->stmts);
=>  if (!last_stmt || last_stmt->type == STMT_LABEL)
=>      last_stmt = last_stmt->label_statement;
    ......
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions