fixed another bug in ps_read_cached (buffer overflow in fact)

This commit is contained in:
TLINDEN
2014-02-26 18:26:44 +01:00
parent c11ce76d21
commit 2b54ac015a
2 changed files with 1 additions and 2 deletions

View File

@@ -8,7 +8,6 @@ extern "C" {
#include "pcp/config.h"
#include "pcp/base85.h"
#include "pcp/buffer.h"
#include "pcp/config.h"
#include "pcp/crypto.h"
#include "pcp/defines.h"
#include "pcp/digital_crc32.h"

View File

@@ -110,7 +110,7 @@ size_t ps_read_raw(Pcpstream *stream, void *buf, size_t readbytes) {
size_t ps_read_cached(Pcpstream *stream, void *buf, size_t readbytes) {
if(buffer_left(stream->cache) <= readbytes && buffer_left(stream->cache) > 0 && readbytes <= stream->blocksize) {
/* enough left in current cache */
return buffer_get_chunk(stream->cache, buf, readbytes);
return buffer_get_chunk(stream->cache, buf, buffer_left(stream->cache));
}
else {
/* request for chunk larger than what we've got in the cache */