Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
buffer: Fix heap overflow when ensuring empty buffer is NUL-terminated
Browse files Browse the repository at this point in the history
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
  • Loading branch information
lpereira committed Sep 29, 2015
1 parent 321ee58 commit 4975b55
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/datatypes/sol-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ sol_buffer_ensure_nul_byte(struct sol_buffer *buf)
if (buf->flags & SOL_BUFFER_FLAGS_NO_NUL_BYTE)
return -EINVAL;

if (*((char *)sol_buffer_at_end(buf) - 1) == '\0')
if (buf->used && *((char *)sol_buffer_at_end(buf) - 1) == '\0')
return 0;

if (buf->used >= SIZE_MAX - 1 ||
Expand Down

0 comments on commit 4975b55

Please sign in to comment.