From dde89765744dad9a6b9d13126092d9bfc2dbc0d7 Mon Sep 17 00:00:00 2001 From: jhurst Date: Fri, 17 Mar 2006 00:41:14 +0000 Subject: release --- src/KLV.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/KLV.cpp') diff --git a/src/KLV.cpp b/src/KLV.cpp index b31969e..63c1e54 100755 --- a/src/KLV.cpp +++ b/src/KLV.cpp @@ -69,6 +69,20 @@ ASDCP::KLVPacket::InitFromBuffer(const byte_t* buf, ui32_t buf_len) return RESULT_FAIL; } + ui32_t ber_len = BER_length(buf + SMPTE_UL_LENGTH); + + if ( ber_len > ( buf_len - SMPTE_UL_LENGTH ) ) + { + DefaultLogSink().Error("BER encoding length exceeds buffer size\n"); + return RESULT_FAIL; + } + + if ( ber_len == 0 ) + { + ASDCP::DefaultLogSink().Error("KLV format error, zero BER length not allowed\n"); + return RESULT_FAIL; + } + ui64_t tmp_size; if ( ! read_BER(buf + SMPTE_UL_LENGTH, &tmp_size) ) return RESULT_FAIL; @@ -148,7 +162,7 @@ ASDCP::KLVFilePacket::InitFromFile(const FileReader& Reader, const byte_t* label return result; } -// +// TODO: refactor to use InitFromBuffer ASDCP::Result_t ASDCP::KLVFilePacket::InitFromFile(const FileReader& Reader) { -- cgit v1.2.3