mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-19 09:25:28 +00:00
Merge pull request #460 from majestrate/master
fix bencode read crash with empty buffer
This commit is contained in:
commit
5d95873e8d
@ -16,6 +16,7 @@
|
||||
|
||||
#include <stdlib.h> // for itoa
|
||||
#include <iostream>
|
||||
#include <util/endian.hpp>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
|
@ -122,6 +122,8 @@ bencode_end(llarp_buffer_t* buff)
|
||||
bool
|
||||
bencode_read_dict(llarp_buffer_t* buff, struct dict_reader* r)
|
||||
{
|
||||
if(buff->size_left() < 2) // minimum case is 'de'
|
||||
return false;
|
||||
llarp_buffer_t strbuf; // temporary buffer for current element
|
||||
r->buffer = buff; // set up dict_reader
|
||||
if(*r->buffer->cur != 'd') // ensure is a dictionary
|
||||
@ -151,6 +153,8 @@ bencode_read_dict(llarp_buffer_t* buff, struct dict_reader* r)
|
||||
bool
|
||||
bencode_read_list(llarp_buffer_t* buff, struct list_reader* r)
|
||||
{
|
||||
if(buff->size_left() < 2) // minimum case is 'le'
|
||||
return false;
|
||||
r->buffer = buff;
|
||||
if(*r->buffer->cur != 'l') // ensure is a list
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user