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

Unified Diff: webrtc/p2p/base/stun_unittest.cc

Issue 2837133003: Don't crash if STUN error message is missing ERROR-CODE attribute. (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/stun.cc ('k') | webrtc/p2p/base/stunport.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/stun_unittest.cc
diff --git a/webrtc/p2p/base/stun_unittest.cc b/webrtc/p2p/base/stun_unittest.cc
index efc11b240874f137918945baebcf84cdf72d916a..15d4648f276f4483b33f398063138c16267c401c 100644
--- a/webrtc/p2p/base/stun_unittest.cc
+++ b/webrtc/p2p/base/stun_unittest.cc
@@ -1016,6 +1016,15 @@ TEST_F(StunTest, ReadErrorCodeAttribute) {
EXPECT_EQ(kTestErrorNumber, errorcode->number());
EXPECT_EQ(kTestErrorReason, errorcode->reason());
EXPECT_EQ(kTestErrorCode, errorcode->code());
+ EXPECT_EQ(kTestErrorCode, msg.GetErrorCodeValue());
+}
+
+// Test that GetErrorCodeValue returns STUN_ERROR_GLOBAL_FAILURE if the message
+// in question doesn't have an error code attribute, rather than crashing.
+TEST_F(StunTest, GetErrorCodeValueWithNoErrorAttribute) {
+ StunMessage msg;
+ ReadStunMessage(&msg, kStunMessageWithIPv6MappedAddress);
+ EXPECT_EQ(STUN_ERROR_GLOBAL_FAILURE, msg.GetErrorCodeValue());
}
TEST_F(StunTest, ReadMessageWithAUInt16ListAttribute) {
« no previous file with comments | « webrtc/p2p/base/stun.cc ('k') | webrtc/p2p/base/stunport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698