libais icon indicating copy to clipboard operation
libais copied to clipboard

Ais8_200_40 is parsed incorrectly (Crash)

Open mb12 opened this issue 8 years ago • 3 comments

Here is a string that consistently reproduces this:

"!AIVDM,1,1,,B,86:hqAh0J010,0*6A"

Ais8_200_40::Ais8_200_40(const char *nmea_payload, const size_t pad)
    : Ais8(nmea_payload, pad), form(0), dir(0), stream_dir(0), status_raw(0),
      spare2(0) {
  assert(dac == 200); <=== This is crashing because dac==1

mb12 avatar Apr 08 '16 17:04 mb12

Hmm... If a dac 1 message is getting to the 8_200_40 decoder, that is definitely a bug. I will look into it when I get a chance.

schwehr avatar Apr 08 '16 19:04 schwehr

How did you parse the message that you ended up with a dac==1 message in Ais8_200_40?

schwehr avatar Apr 08 '16 19:04 schwehr

I've copy pasted the code below.

static void testSchwehrVector(const vector<string>& lines) {
    libais::VdmStream stream;
    for (const string &line : lines) {
        bool lineAdded = stream.AddLine(line);
        if(!lineAdded) {
            // Either line is not AIS line or
            std::cerr<< "Could not handle" << line << std::endl;
        }
    }
    while(!stream.empty()) {
        std::unique_ptr<libais::AisMsg>aisMessage = stream.PopOldestMessage();
        if((aisMessage != nullptr) && !aisMessage->had_error()) {
            int message_id = aisMessage->message_id;
            std::cerr << "Type:" <<message_id;
        }
    }
}

static void test7() {
  const vector<string> lines = {
"!AIVDM,1,1,,B,86:hqAh0J010,0*6A"
};
  testSchwehrVector(lines); 
}

mb12 avatar Apr 08 '16 20:04 mb12