Skip to content

Incorrect model of calloc with respect to memory safety #586

Description

@shaobo-he

When the size argument of calloc is 0, it should return a pointer without triggering any memory-safety issues whereas SMACK reports memory safety violations. This is because we do a memset to the malloced pointer which can be 0 when the size is 0 whereas memset is checked for valid pointer dereference. The following is a reproduction,

#include <stdlib.h>
int main() {
  int *a = calloc(0, sizeof(int));
  free(a);
  return 0;
}

Invoking SMACK with --memory-safety produces an error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions