ss: Check return value of FileChannel.read() call
authorAlexandre Montplaisir <alexmonthy@efficios.com>
Tue, 20 Sep 2016 16:26:31 +0000 (12:26 -0400)
committerAlexandre Montplaisir <alexmonthy@efficios.com>
Wed, 21 Sep 2016 17:15:50 +0000 (13:15 -0400)
Fixes a Coverity warning.

Change-Id: Ic11af8b32d7dccf136812400a689964c04bedf50
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/81497
Reviewed-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTreeClassic.java

index 29f62481c04ba90eef281732e882936349da837c..461fbf6eb22ab0a0fdef1de3fc817cba7759e2e3 100644 (file)
@@ -141,10 +141,14 @@ public class HistoryTreeClassic implements IHistoryTree {
                 FileChannel fc = fis.getChannel();) {
 
             ByteBuffer buffer = ByteBuffer.allocate(TREE_HEADER_SIZE);
-
             buffer.order(ByteOrder.LITTLE_ENDIAN);
             buffer.clear();
-            fc.read(buffer);
+
+            res = fc.read(buffer);
+            if (res != TREE_HEADER_SIZE) {
+                throw new IOException("Invalid header size"); //$NON-NLS-1$
+            }
+
             buffer.flip();
 
             /*
This page took 0.026159 seconds and 5 git commands to generate.