Merge pull request #651 from xetorthio/protocol_bound_fix
Checks for buffer out of bounds before writing to the stream. Fixes #636
This commit is contained in:
@@ -4,6 +4,7 @@ import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -38,6 +39,28 @@ public class ProtocolTest extends JedisTestBase {
|
||||
|
||||
assertEquals(expectedCommand, sb.toString());
|
||||
}
|
||||
|
||||
@Test(expected=IOException.class)
|
||||
public void writeOverflow() throws IOException {
|
||||
RedisOutputStream ros = new RedisOutputStream(new OutputStream() {
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
throw new IOException("thrown exception");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ros.write(new byte[8191]);
|
||||
|
||||
try {
|
||||
ros.write((byte)'*');
|
||||
} catch (IOException ioe) {}
|
||||
|
||||
|
||||
ros.write((byte)'*');
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bulkReply() {
|
||||
|
||||
Reference in New Issue
Block a user