Skip to content

Commit

Permalink
Adds pre- and post-conditions to s2n_stuffer_resize (aws#2191)
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe R. Monteiro <[email protected]>
  • Loading branch information
feliperodri authored Jul 30, 2020
1 parent 34ee087 commit 3083cf5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion stuffer/s2n_stuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ int s2n_stuffer_free(struct s2n_stuffer *stuffer)

int s2n_stuffer_resize(struct s2n_stuffer *stuffer, const uint32_t size)
{
PRECONDITION_POSIX(s2n_stuffer_is_valid(stuffer));
ENSURE_POSIX(!stuffer->tainted, S2N_ERR_RESIZE_TAINTED_STUFFER);
ENSURE_POSIX(stuffer->growable, S2N_ERR_RESIZE_STATIC_STUFFER);

Expand All @@ -108,11 +109,12 @@ int s2n_stuffer_resize(struct s2n_stuffer *stuffer, const uint32_t size)
if (stuffer->write_cursor > size) stuffer->write_cursor = size;
if (stuffer->high_water_mark > size) stuffer->high_water_mark = size;
stuffer->blob.size = size;
POSTCONDITION_POSIX(s2n_stuffer_is_valid(stuffer));
return S2N_SUCCESS;
}

GUARD(s2n_realloc(&stuffer->blob, size));

POSTCONDITION_POSIX(s2n_stuffer_is_valid(stuffer));
return S2N_SUCCESS;
}

Expand Down

0 comments on commit 3083cf5

Please sign in to comment.