Skip to content

Commit 6fe1c35

Browse files
committed
pcp: make NAT-PMP error codes uint16_t
They are defined as being 16 bits in the RFC and correctly parsed in the code which may result in an implicit conversion from uint16_t to uint8_t.
1 parent 01906ce commit 6fe1c35

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/common/pcp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ constexpr uint8_t NATPMP_RESULT_UNSUPP_VERSION = 1;
8484
constexpr uint8_t NATPMP_RESULT_NO_RESOURCES = 4;
8585

8686
//! Mapping of NATPMP result code to string (RFC6886 3.5). Result codes <=2 match PCP.
87-
const std::map<uint8_t, std::string> NATPMP_RESULT_STR{
87+
const std::map<uint16_t, std::string> NATPMP_RESULT_STR{
8888
{0, "SUCCESS"},
8989
{1, "UNSUPP_VERSION"},
9090
{2, "NOT_AUTHORIZED"},
@@ -165,7 +165,7 @@ const std::map<uint8_t, std::string> PCP_RESULT_STR{
165165
};
166166

167167
//! Return human-readable string from NATPMP result code.
168-
std::string NATPMPResultString(uint8_t result_code)
168+
std::string NATPMPResultString(uint16_t result_code)
169169
{
170170
auto result_i = NATPMP_RESULT_STR.find(result_code);
171171
return strprintf("%s (code %d)", result_i == NATPMP_RESULT_STR.end() ? "(unknown)" : result_i->second, result_code);

0 commit comments

Comments
 (0)