diff --git a/ingest/src/ingest/bufr/ESOHBufr.cpp b/ingest/src/ingest/bufr/ESOHBufr.cpp index 3049904d..1b064419 100644 --- a/ingest/src/ingest/bufr/ESOHBufr.cpp +++ b/ingest/src/ingest/bufr/ESOHBufr.cpp @@ -246,7 +246,9 @@ std::list ESOHBufr::msg() const { LogEntry("Missing WMO Station number after WMO block", LogLevel::WARN, __func__, bufr_id)); } - wigos_id.setWmoId(wmo_block * 1000 + wmo_station); + if (!wigos_id.getWigosLocalId().size()) { + wigos_id.setWmoId(wmo_block * 1000 + wmo_station); + } skip_platform = false; // platform_check = true; break; diff --git a/ingest/src/ingest/bufr/NorBufr.cpp b/ingest/src/ingest/bufr/NorBufr.cpp index bba2171e..c17e7e7b 100644 --- a/ingest/src/ingest/bufr/NorBufr.cpp +++ b/ingest/src/ingest/bufr/NorBufr.cpp @@ -640,14 +640,14 @@ uint64_t NorBufr::fromBuffer(char *ext_buf, u_int64_t ext_buf_pos, if (n >= ext_buf_size) { lb.addLogEntry( LogEntry("No more BUFR messages", LogLevel::WARN, __func__, bufr_id)); - return 0; + return n; } // Section0 length uint64_t slen = 8; uint8_t sec0[slen]; - if (ext_buf_pos + slen < ext_buf_size) { - memcpy(sec0, ext_buf + ext_buf_pos, slen); + if (ext_buf_pos + n + slen < ext_buf_size) { + memcpy(sec0, ext_buf + ext_buf_pos + n, slen); } len = NorBufrIO::getBytes(sec0 + 4, 3); @@ -660,8 +660,8 @@ uint64_t NorBufr::fromBuffer(char *ext_buf, u_int64_t ext_buf_pos, buffer = new uint8_t[len]; memcpy(buffer, sec0, slen); - if (ext_buf_pos + len <= ext_buf_size) { - memcpy(buffer + slen, ext_buf + ext_buf_pos + slen, len - slen); + if (ext_buf_pos + n + len <= ext_buf_size) { + memcpy(buffer + slen, ext_buf + ext_buf_pos + n + slen, len - slen); } int offset = checkBuffer(); diff --git a/ingest/src/ingest/bufr/NorBufrIO.cpp b/ingest/src/ingest/bufr/NorBufrIO.cpp index 886eef71..60ad2e9d 100644 --- a/ingest/src/ingest/bufr/NorBufrIO.cpp +++ b/ingest/src/ingest/bufr/NorBufrIO.cpp @@ -63,8 +63,9 @@ uint64_t NorBufrIO::findBytes(char *buf, unsigned int buf_size, const char *seq, unsigned int size) { uint64_t j = 0; char c; - while (j < size && j < buf_size) { - c = buf[j]; + uint64_t position = 0; + while (j < size && position < buf_size) { + c = buf[position]; if (c == seq[j]) { ++j; } else { @@ -74,8 +75,9 @@ uint64_t NorBufrIO::findBytes(char *buf, unsigned int buf_size, const char *seq, j = 0; } } + ++position; } - return (j < size ? ULONG_MAX : j); + return (j < size ? ULONG_MAX : position - size); } uint64_t NorBufrIO::getBytes(uint8_t *buffer, int size) { diff --git a/ingest/src/ingest/bufr/bufresohmsg_py.cpp b/ingest/src/ingest/bufr/bufresohmsg_py.cpp index b7e1a501..1c1f6783 100644 --- a/ingest/src/ingest/bufr/bufresohmsg_py.cpp +++ b/ingest/src/ingest/bufr/bufresohmsg_py.cpp @@ -135,9 +135,9 @@ std::list norbufr_bufresohmsg(std::string fname) { std::list norbufr_bufresohmsgmem(char *api_buf, int api_size) { std::list ret; - int position = 0; + uint64_t position = 0; - while (position < api_size) { + while (position < static_cast(api_size)) { ESOHBufr *bufr = new ESOHBufr; // TODO: @@ -146,7 +146,9 @@ std::list norbufr_bufresohmsgmem(char *api_buf, int api_size) { bufr->setMsgTemplate(bufr_input_schema); bufr->setShadowWigos(default_shadow_wigos_py); - int n = bufr->fromBuffer(api_buf, position, api_size); + uint64_t n = bufr->fromBuffer(api_buf, position, api_size); + if (n == ULONG_MAX) + position = ULONG_MAX; if (n > position) { position = n; bufr->setTableB(