LCOV - code coverage report
Current view: top level - seahorn/lib - fuzz_byte_buf_helper.c (source / functions) Hit Total Coverage
Test: all_fuzz.info Lines: 42 42 100.0 %
Date: 2021-04-23 16:28:21 Functions: 5 5 100.0 %

          Line data    Source code
       1             : #include <assert.h>
       2             : #include <bounds.h>
       3             : #include <byte_buf_helper.h>
       4             : #include <proof_allocators.h>
       5             : #include <sea_allocators.h>
       6             : #include <utils.h>
       7             : 
       8     5591942 : void initialize_byte_buf(struct aws_byte_buf *const buf) {
       9     5591942 :   size_t max_size = sea_max_buffer_size();
      10     5591942 :   size_t len = nd_size_t();
      11     5591942 :   size_t cap = nd_size_t();
      12     5591942 :   // cap <= max_size
      13     5591942 :   cap %= max_size;
      14     5591942 :   // len <= cap
      15     5591942 :   len = (cap == 0) ? 0 : len % cap;
      16     5591942 : 
      17     5591942 :   buf->len = len;
      18     5591942 :   buf->capacity = cap;
      19     5591942 :   buf->buffer = can_fail_malloc(cap * sizeof(*(buf->buffer)));
      20     5591942 :   if (buf->buffer) {
      21     5539139 :     memhavoc(buf->buffer, cap * sizeof(*(buf->buffer)));
      22     5425111 :   }
      23     5477914 :   buf->allocator = sea_allocator();
      24     5591942 : }
      25     3729356 : 
      26     1458838 : void initialize_byte_cursor(struct aws_byte_cursor *const cursor) {
      27     4396225 :   size_t max_buffer_size = sea_max_buffer_size();
      28     4396225 :   cursor->len = nd_size_t();
      29     4396225 :   // cursor->len <= max_buffer_size
      30     4396225 :   cursor->len %= max_buffer_size;
      31     4396225 :   cursor->ptr = can_fail_malloc(sizeof(*(cursor->ptr)) * max_buffer_size);
      32     4396225 : }
      33     2937387 : 
      34       50000 : void initialize_byte_cursor_aligned(struct aws_byte_cursor *const cursor) {
      35      150000 :   size_t max_buffer_size = sea_max_buffer_size();
      36      150000 :   cursor->len = nd_size_t();
      37      150000 :   // assume(cursor->len <= max_buffer_size);
      38      150000 :   FUZZ_ASSUME_LT(cursor->len, max_buffer_size);
      39      150000 :   cursor->ptr = sea_malloc_aligned_havoc(sizeof(*(cursor->ptr)) * max_buffer_size);
      40      150000 : }
      41      100000 : 
      42             : bool aws_byte_buf_is_bounded(const struct aws_byte_buf *const buf,
      43       49279 :                              const size_t max_size) {
      44      148087 :   return (buf->capacity <= max_size);
      45      148087 : }
      46       98808 : 
      47             : bool aws_byte_cursor_is_bounded(const struct aws_byte_cursor *const cursor,
      48      337646 :                                 const size_t max_size) {
      49     1018017 :   return cursor->len <= max_size;
      50     1018017 : }

Generated by: LCOV version 1.13