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

Side by Side Diff: webrtc/p2p/base/stun.cc

Issue 2837133003: Don't crash if STUN error message is missing ERROR-CODE attribute. (Closed)
Patch Set: Created 3 years, 7 months 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
« no previous file with comments | « webrtc/p2p/base/stun.h ('k') | webrtc/p2p/base/stun_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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 const StunByteStringAttribute* StunMessage::GetByteString(int type) const { 109 const StunByteStringAttribute* StunMessage::GetByteString(int type) const {
110 return static_cast<const StunByteStringAttribute*>(GetAttribute(type)); 110 return static_cast<const StunByteStringAttribute*>(GetAttribute(type));
111 } 111 }
112 112
113 const StunErrorCodeAttribute* StunMessage::GetErrorCode() const { 113 const StunErrorCodeAttribute* StunMessage::GetErrorCode() const {
114 return static_cast<const StunErrorCodeAttribute*>( 114 return static_cast<const StunErrorCodeAttribute*>(
115 GetAttribute(STUN_ATTR_ERROR_CODE)); 115 GetAttribute(STUN_ATTR_ERROR_CODE));
116 } 116 }
117 117
118 int StunMessage::GetErrorCodeValue() const {
119 const StunErrorCodeAttribute* error_attribute = GetErrorCode();
120 return error_attribute ? error_attribute->code() : STUN_ERROR_GLOBAL_FAILURE;
121 }
122
118 const StunUInt16ListAttribute* StunMessage::GetUnknownAttributes() const { 123 const StunUInt16ListAttribute* StunMessage::GetUnknownAttributes() const {
119 return static_cast<const StunUInt16ListAttribute*>( 124 return static_cast<const StunUInt16ListAttribute*>(
120 GetAttribute(STUN_ATTR_UNKNOWN_ATTRIBUTES)); 125 GetAttribute(STUN_ATTR_UNKNOWN_ATTRIBUTES));
121 } 126 }
122 127
123 // Verifies a STUN message has a valid MESSAGE-INTEGRITY attribute, using the 128 // Verifies a STUN message has a valid MESSAGE-INTEGRITY attribute, using the
124 // procedure outlined in RFC 5389, section 15.4. 129 // procedure outlined in RFC 5389, section 15.4.
125 bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size, 130 bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size,
126 const std::string& password) { 131 const std::string& password) {
127 // Verifying the size of the message. 132 // Verifying the size of the message.
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 digest, sizeof(digest)); 923 digest, sizeof(digest));
919 if (size == 0) { 924 if (size == 0) {
920 return false; 925 return false;
921 } 926 }
922 927
923 *hash = std::string(digest, size); 928 *hash = std::string(digest, size);
924 return true; 929 return true;
925 } 930 }
926 931
927 } // namespace cricket 932 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/stun.h ('k') | webrtc/p2p/base/stun_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698