|
@@ -142,6 +142,12 @@ init() {
|
|
|
_file_stdfloat_double = scan.get_bool();
|
|
_file_stdfloat_double = scan.get_bool();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (scan.get_current_index() > header.get_length()) {
|
|
|
|
|
+ bam_cat.error()
|
|
|
|
|
+ << "Bam header is too short.\n";
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1230,6 +1236,12 @@ p_read_object() {
|
|
|
|
|
|
|
|
int object_id = read_object_id(scan);
|
|
int object_id = read_object_id(scan);
|
|
|
|
|
|
|
|
|
|
+ if (scan.get_current_index() > dg.get_length()) {
|
|
|
|
|
+ bam_cat.error()
|
|
|
|
|
+ << "Found truncated datagram in bam stream\n";
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// There are two cases (not counting the special _remove_flag case,
|
|
// There are two cases (not counting the special _remove_flag case,
|
|
|
// above). Either this is a new object definition, or this is a
|
|
// above). Either this is a new object definition, or this is a
|
|
|
// reference to an object that was previously defined.
|
|
// reference to an object that was previously defined.
|
|
@@ -1271,6 +1283,12 @@ p_read_object() {
|
|
|
created_obj._ptr->fillin(scan, this);
|
|
created_obj._ptr->fillin(scan, this);
|
|
|
_now_creating = was_creating;
|
|
_now_creating = was_creating;
|
|
|
|
|
|
|
|
|
|
+ if (scan.get_remaining_size() > 0) {
|
|
|
|
|
+ bam_cat.warning()
|
|
|
|
|
+ << "Skipping " << scan.get_remaining_size() << " remaining bytes "
|
|
|
|
|
+ << "in datagram containing type " << type << "\n";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
// We are receiving a new object. Now we can call the factory
|
|
// We are receiving a new object. Now we can call the factory
|
|
|
// to create the object.
|
|
// to create the object.
|
|
@@ -1371,6 +1389,13 @@ p_read_object() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // Sanity check that we read the expected number of bytes.
|
|
|
|
|
+ if (scan.get_current_index() > dg.get_length()) {
|
|
|
|
|
+ bam_cat.error()
|
|
|
|
|
+ << "End of datagram reached while reading bam object "
|
|
|
|
|
+ << type << ": " << (void *)created_obj._ptr << "\n";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return object_id;
|
|
return object_id;
|