Skip to content

Commit 7b09c12

Browse files
committed
Merge pull request #9 from maxmind/greg/coverity-fixes
Fix issues found by Coverity
2 parents 830e773 + 6649cc3 commit 7b09c12

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,17 @@ notifications:
1616
1717
on_success: change
1818
on_failure: always
19+
20+
env:
21+
global:
22+
- secure: "KXF3RVBZDxeASAnleYlTaqvxRRB9FSzSAdVV9h7Kw81+p4UO64b8CPJR1p4fLIVwAp8C4R8h0xZDN3pAv/iyeA4ndIeh9tQXNZBm737RE5x+6x6nf/shP/Em1w9T1s3KmretXoTFK5NJGv2yTesgaIAV/JV1OFvlG6ArswhrPFc="
23+
24+
addons:
25+
coverity_scan:
26+
project:
27+
name: "maxmind/MaxMind-DB-Reader-java"
28+
description: "Build submitted via Travis CI"
29+
notification_email: [email protected]
30+
build_command_prepend: "mvn clean"
31+
build_command: "mvn -DskipTests=true compile"
32+
branch_pattern: .*coverity.*

src/main/java/com/maxmind/db/BufferHolder.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ final class BufferHolder {
2222
final FileChannel channel = file.getChannel();
2323
if (mode == FileMode.MEMORY) {
2424
this.buffer = ByteBuffer.wrap(new byte[(int) channel.size()]);
25-
channel.read(this.buffer);
25+
if (channel.read(this.buffer) != this.buffer.capacity()) {
26+
throw new IOException("Unable to read "
27+
+ database.getName()
28+
+ " into memory. Unexpected end of stream.");
29+
}
2630
} else {
2731
this.buffer = channel.map(MapMode.READ_ONLY, 0, channel.size());
2832
}

src/main/java/com/maxmind/db/Decoder.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,7 @@
77

88
import com.fasterxml.jackson.databind.JsonNode;
99
import com.fasterxml.jackson.databind.ObjectMapper;
10-
import com.fasterxml.jackson.databind.node.ArrayNode;
11-
import com.fasterxml.jackson.databind.node.BigIntegerNode;
12-
import com.fasterxml.jackson.databind.node.BinaryNode;
13-
import com.fasterxml.jackson.databind.node.BooleanNode;
14-
import com.fasterxml.jackson.databind.node.DoubleNode;
15-
import com.fasterxml.jackson.databind.node.FloatNode;
16-
import com.fasterxml.jackson.databind.node.IntNode;
17-
import com.fasterxml.jackson.databind.node.LongNode;
18-
import com.fasterxml.jackson.databind.node.ObjectNode;
19-
import com.fasterxml.jackson.databind.node.TextNode;
10+
import com.fasterxml.jackson.databind.node.*;
2011

2112
/*
2213
* Decoder for MaxMind DB data.
@@ -55,7 +46,7 @@ public static Type fromControlByte(int b) {
5546
}
5647
}
5748

58-
class Result {
49+
static class Result {
5950
private final JsonNode node;
6051
private int offset;
6152

0 commit comments

Comments
 (0)