Skip to content

UB in autrace #517

@mimicria

Description

@mimicria

Hi
A bug was found in the autrace utility when the -r parameter is passed, but its value is omitted.
At the beginning, cmd is initialized by 1:

int pid,cmd=1;

If -r argument is found, the value of cmd is incremented
if (strcmp(argv[cmd], "-r") == 0) {
threat = 1;
cmd++;

Next access to the argv[cmd] element without checking its presence
if (access(argv[cmd], X_OK)) {

Steps to reproduce:

  1. build with UBSAN (-fsanitize=undefined)
  2. run autrace -r
autrace.c:182:13: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/unistd.h:287:60: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior autrace.c:182:13 in
Error checking (null) (Bad address)

Bug was found with Svace static analyzer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions