Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: dbus/message.cc

Issue 8525012: dbus: Fix a bug where we rejected an empty array in PopArrayOfBytes() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor change Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dbus/message_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "dbus/message.h" 5 #include "dbus/message.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 } 748 }
749 749
750 bool MessageReader::PopVariant(MessageReader* sub_reader) { 750 bool MessageReader::PopVariant(MessageReader* sub_reader) {
751 return PopContainer(DBUS_TYPE_VARIANT, sub_reader); 751 return PopContainer(DBUS_TYPE_VARIANT, sub_reader);
752 } 752 }
753 753
754 bool MessageReader::PopArrayOfBytes(uint8** bytes, size_t* length) { 754 bool MessageReader::PopArrayOfBytes(uint8** bytes, size_t* length) {
755 MessageReader array_reader(message_); 755 MessageReader array_reader(message_);
756 if (!PopArray(&array_reader)) 756 if (!PopArray(&array_reader))
757 return false; 757 return false;
758 // An empty array is allowed.
759 if (!array_reader.HasMoreData()) {
760 *length = 0;
761 *bytes = NULL;
762 return true;
763 }
758 if (!array_reader.CheckDataType(DBUS_TYPE_BYTE)) 764 if (!array_reader.CheckDataType(DBUS_TYPE_BYTE))
759 return false; 765 return false;
760 int int_length = 0; 766 int int_length = 0;
761 dbus_message_iter_get_fixed_array(&array_reader.raw_message_iter_, 767 dbus_message_iter_get_fixed_array(&array_reader.raw_message_iter_,
762 bytes, 768 bytes,
763 &int_length); 769 &int_length);
764 *length = static_cast<int>(int_length); 770 *length = static_cast<int>(int_length);
765 return bytes != NULL; 771 return true;
766 } 772 }
767 773
768 bool MessageReader::PopArrayOfStrings( 774 bool MessageReader::PopArrayOfStrings(
769 std::vector<std::string> *strings) { 775 std::vector<std::string> *strings) {
770 MessageReader array_reader(message_); 776 MessageReader array_reader(message_);
771 if (!PopArray(&array_reader)) 777 if (!PopArray(&array_reader))
772 return false; 778 return false;
773 while (array_reader.HasMoreData()) { 779 while (array_reader.HasMoreData()) {
774 std::string string; 780 std::string string;
775 if (!array_reader.PopString(&string)) 781 if (!array_reader.PopString(&string))
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 } 894 }
889 895
890 bool MessageReader::PopVariantOfBasic(int dbus_type, void* value) { 896 bool MessageReader::PopVariantOfBasic(int dbus_type, void* value) {
891 dbus::MessageReader variant_reader(message_); 897 dbus::MessageReader variant_reader(message_);
892 if (!PopVariant(&variant_reader)) 898 if (!PopVariant(&variant_reader))
893 return false; 899 return false;
894 return variant_reader.PopBasic(dbus_type, value); 900 return variant_reader.PopBasic(dbus_type, value);
895 } 901 }
896 902
897 } // namespace dbus 903 } // namespace dbus
OLDNEW
« no previous file with comments | « no previous file | dbus/message_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698