Ver Fonte

*** empty log message ***

David Rose há 25 anos atrás
pai
commit
0255c01463
2 ficheiros alterados com 12 adições e 4 exclusões
  1. 2 1
      pandatool/src/flt/Sources.pp
  2. 10 3
      pandatool/src/flt/fltRecordReader.cxx

+ 2 - 1
pandatool/src/flt/Sources.pp

@@ -50,7 +50,8 @@
   #define LOCAL_LIBS \
   #define LOCAL_LIBS \
     flt
     flt
   #define OTHER_LIBS \
   #define OTHER_LIBS \
-    pystub
+    express:c pandaexpress:m \
+    dtoolutil:c dconfig:c dtool:m pystub
 
 
   #define SOURCES \
   #define SOURCES \
     test_flt.cxx
     test_flt.cxx

+ 10 - 3
pandatool/src/flt/fltRecordReader.cxx

@@ -116,7 +116,7 @@ advance(bool ok_eof) {
   char bytes[header_size];
   char bytes[header_size];
   _in.read(bytes, header_size);
   _in.read(bytes, header_size);
 
 
-  if ((int)_in.gcount() < header_size && _in.eof()) {
+  if (_in.eof()) {
     _state = S_eof;
     _state = S_eof;
     if (ok_eof) {
     if (ok_eof) {
       return FE_ok;
       return FE_ok;
@@ -136,6 +136,11 @@ advance(bool ok_eof) {
   _opcode = (FltOpcode)dgi.get_be_int16();
   _opcode = (FltOpcode)dgi.get_be_int16();
   _record_length = dgi.get_be_uint16();
   _record_length = dgi.get_be_uint16();
 
 
+  if (_record_length < header_size) {
+    assert(!flt_error_abort);
+    return FE_invalid_record;
+  }
+
   if (flt_cat.is_debug()) {
   if (flt_cat.is_debug()) {
     flt_cat.debug()
     flt_cat.debug()
       << "Reading " << _opcode << " of length " << _record_length << "\n";
       << "Reading " << _opcode << " of length " << _record_length << "\n";
@@ -144,11 +149,13 @@ advance(bool ok_eof) {
   // And now read the full record based on the length.
   // And now read the full record based on the length.
   int length = _record_length - header_size;
   int length = _record_length - header_size;
   char *buffer = new char[length];
   char *buffer = new char[length];
-  _in.read(buffer, length);
+  if (length > 0) {
+    _in.read(buffer, length);
+  }
   _datagram = Datagram(buffer, length);
   _datagram = Datagram(buffer, length);
   delete[] buffer;
   delete[] buffer;
 
 
-  if ((int)_in.gcount() < length && _in.eof()) {
+  if (_in.eof()) {
     _state = S_eof;
     _state = S_eof;
     assert(!flt_error_abort);
     assert(!flt_error_abort);
     return FE_end_of_file;
     return FE_end_of_file;