From bf685ed428c7ecbd0c76828ccec392473fafb9d4 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Thu, 6 Aug 2015 14:04:51 +0200 Subject: Set failbit on negative length --- src/tag_array.cpp | 8 ++++++-- src/tag_list.cpp | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tag_array.cpp b/src/tag_array.cpp index 94b8ffe7ac..f83bce11f7 100644 --- a/src/tag_array.cpp +++ b/src/tag_array.cpp @@ -107,7 +107,9 @@ void tag_array::read_payload(io::stream_reader& reader) { int32_t length; reader.read_num(length); - if(length < 0 || !reader.get_istr()) + if(length < 0) + reader.get_istr().setstate(std::ios::failbit); + if(!reader.get_istr()) throw io::input_error("Error reading length of tag_byte_array"); data.resize(length); @@ -121,7 +123,9 @@ void tag_array::read_payload(io::stream_reader& reader) { int32_t length; reader.read_num(length); - if(length < 0 || !reader.get_istr()) + if(length < 0) + reader.get_istr().setstate(std::ios::failbit); + if(!reader.get_istr()) throw io::input_error("Error reading length of tag_int_array"); data.clear(); diff --git a/src/tag_list.cpp b/src/tag_list.cpp index 53c1a8e392..f5a5b91758 100644 --- a/src/tag_list.cpp +++ b/src/tag_list.cpp @@ -138,7 +138,9 @@ void tag_list::read_payload(io::stream_reader& reader) int32_t length; reader.read_num(length); - if(length < 0 || !reader.get_istr()) + if(length < 0) + reader.get_istr().setstate(std::ios::failbit); + if(!reader.get_istr()) throw io::input_error("Error reading length of tag_list"); if(lt != tag_type::End) -- cgit 0.0.5-2-1-g0f52