fix out-of-bounds case in parser
authorChristian Grothoff <christian@grothoff.org>
Fri, 10 Mar 2017 17:00:53 +0000 (18:00 +0100)
committerChristian Grothoff <christian@grothoff.org>
Fri, 10 Mar 2017 17:00:53 +0000 (18:00 +0100)
src/testbed/testbed_api_topology.c

index a21a7cf53a37ef94cbbc820da5da1bce7318bb9e..544f127a91b6c365aa5890d090e4897410f1259e 100644 (file)
@@ -1147,9 +1147,11 @@ gen_topo_from_file (struct TopologyContext *tc,
              other_peer_id);
       while (('\n' != data[offset]) && ('|' != data[offset]) && (offset < fs))
         offset++;
-      if ('\n' == data[offset])
+      if ( (offset < fs) &&
+           ('\n' == data[offset]) )
         state = PEER_INDEX;
-      else if ('|' == data[offset])
+      else if ( (offset < fs) &&
+                ('|' == data[offset]) )
       {
         state = OTHER_PEER_INDEX;
         offset++;