Merge pull request #264 from neuroscr/issue263

fix buffer overrun
This commit is contained in:
Ryan Tharp 2019-01-30 23:56:20 -08:00 committed by GitHub
commit 4fbc0ee056
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,8 +50,8 @@ llarp_buffer_read_until(llarp_buffer_t* buff, char delim, byte_t* result,
{
size_t read = 0;
while(*buff->cur != delim && resultsize
&& (buff->cur != buff->base + buff->sz))
// do the bound check first, to avoid over running
while((buff->cur != buff->base + buff->sz) && *buff->cur != delim && resultsize)
{
*result = *buff->cur;
buff->cur++;