| 237 | } |
| 238 | |
| 239 | bool message_impl::deserialize(vsomeip_v3::deserializer* _from) { |
| 240 | bool is_successful; |
| 241 | bool option_is_successful(true); |
| 242 | |
| 243 | // header |
| 244 | is_successful = header_.deserialize(_from); |
| 245 | |
| 246 | // flags |
| 247 | is_successful = is_successful && _from->deserialize(flags_); |
| 248 | |
| 249 | // reserved |
| 250 | uint32_t reserved; |
| 251 | is_successful = is_successful && _from->deserialize(reserved, true); |
| 252 | |
| 253 | // entries |
| 254 | uint32_t entries_length = 0; |
| 255 | is_successful = is_successful && _from->deserialize(entries_length); |
| 256 | |
| 257 | // backup the current remaining length |
| 258 | uint32_t save_remaining = uint32_t(_from->get_remaining()); |
| 259 | if (!is_successful) { |
| 260 | // couldn't deserialize entries length |
| 261 | return is_successful; |
| 262 | } else if (entries_length > save_remaining) { |
| 263 | // not enough data available to deserialize entries array |
| 264 | is_successful = false; |
| 265 | return is_successful; |
| 266 | } |
| 267 | |
| 268 | // set remaining bytes to length of entries array |
| 269 | _from->set_remaining(entries_length); |
| 270 | |
| 271 | // deserialize the entries |
| 272 | while (is_successful && _from->get_remaining()) { |
| 273 | std::shared_ptr<entry_impl> its_entry(deserialize_entry(_from)); |
| 274 | if (its_entry) { |
| 275 | entries_.push_back(its_entry); |
| 276 | } else { |
| 277 | is_successful = false; |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | // set length to remaining bytes after entries array |
| 282 | _from->set_remaining(save_remaining - entries_length); |
| 283 | |
| 284 | // Don't try to deserialize options if there aren't any |
| 285 | if (_from->get_remaining() == 0) { |
| 286 | return is_successful; |
| 287 | } |
| 288 | |
| 289 | // deserialize the options |
| 290 | is_successful = is_successful && _from->deserialize(options_length_); |
| 291 | |
| 292 | // check if there is unreferenced data behind the last option and discard it |
| 293 | if (_from->get_remaining() > options_length_) { |
| 294 | _from->set_remaining(options_length_); |
| 295 | } |
| 296 |
no test coverage detected