mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 12:00:56 +01:00
fixed another bug in ps_read_cached (buffer overflow in fact)
This commit is contained in:
@@ -8,7 +8,6 @@ extern "C" {
|
|||||||
#include "pcp/config.h"
|
#include "pcp/config.h"
|
||||||
#include "pcp/base85.h"
|
#include "pcp/base85.h"
|
||||||
#include "pcp/buffer.h"
|
#include "pcp/buffer.h"
|
||||||
#include "pcp/config.h"
|
|
||||||
#include "pcp/crypto.h"
|
#include "pcp/crypto.h"
|
||||||
#include "pcp/defines.h"
|
#include "pcp/defines.h"
|
||||||
#include "pcp/digital_crc32.h"
|
#include "pcp/digital_crc32.h"
|
||||||
|
|||||||
@@ -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) {
|
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) {
|
if(buffer_left(stream->cache) <= readbytes && buffer_left(stream->cache) > 0 && readbytes <= stream->blocksize) {
|
||||||
/* enough left in current cache */
|
/* 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 {
|
else {
|
||||||
/* request for chunk larger than what we've got in the cache */
|
/* request for chunk larger than what we've got in the cache */
|
||||||
|
|||||||
Reference in New Issue
Block a user