fix buffer overflow
This commit is contained in:
parent
d5b480cf22
commit
3c5efd17bd
@ -600,9 +600,11 @@ public class MapDatabase implements IMapDatabase {
|
||||
private int readBuffer(int size) throws IOException {
|
||||
int read = 0;
|
||||
|
||||
// check if buffer already contains the request bytes
|
||||
if (mBufferPos + size < mBufferSize)
|
||||
return mBufferSize - mBufferPos;
|
||||
|
||||
// check if inputstream is read to the end
|
||||
if (mReadPos == mContentLenth)
|
||||
return mBufferSize - mBufferPos;
|
||||
|
||||
@ -617,8 +619,11 @@ public class MapDatabase implements IMapDatabase {
|
||||
if (mBufferSize == mBufferPos) {
|
||||
mBufferPos = 0;
|
||||
mBufferSize = 0;
|
||||
} else if (mBufferPos + (size - mBufferSize) > BUFFER_SIZE) {
|
||||
Log.d(TAG, "wrap buffer" + (size - mBufferSize) + " " + mBufferPos);
|
||||
} else if (mBufferPos + size > BUFFER_SIZE) {
|
||||
// Log.d(TAG, "wrap buffer - read:" + size
|
||||
// + " cur size:" + mBufferSize
|
||||
// + " cur pos:" + mBufferPos);
|
||||
|
||||
// copy bytes left to read to the beginning of buffer
|
||||
mBufferSize -= mBufferPos;
|
||||
System.arraycopy(mReadBuffer, mBufferPos, mReadBuffer, 0, mBufferSize);
|
||||
|
Loading…
x
Reference in New Issue
Block a user