mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-18 10:57:18 -05:00
fix a bug with ip serialization when ip or port is 0
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1906 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5f7bc6e69d
commit
1a080e1427
@ -587,11 +587,19 @@ bool SetTlvIpAddrPortV4(void *data, uint32_t size, uint32_t *offset,
|
||||
bool ok = true;
|
||||
ok &= SetTlvBase(data, tlvend, offset, type, tlvsize);
|
||||
|
||||
/* now add the data .... (its already in network order) - so flip */
|
||||
uint32_t ipaddr = out->sin_addr.s_addr;
|
||||
sockaddr_in addr = *out;
|
||||
//it looks like if ip or port is null that there is a problem
|
||||
if (addr.sin_addr.s_addr == 0) {
|
||||
addr.sin_addr.s_addr = 1;
|
||||
}
|
||||
if (addr.sin_port == 0) {
|
||||
addr.sin_port = 1;
|
||||
}
|
||||
/* now add the data .... (its already in network order) - so flip */
|
||||
uint32_t ipaddr = addr.sin_addr.s_addr;
|
||||
ok &= setRawUInt32(data, tlvend, offset, ntohl(ipaddr));
|
||||
|
||||
uint16_t port = out->sin_port;
|
||||
uint16_t port = addr.sin_port;
|
||||
ok &= setRawUInt16(data, tlvend, offset, ntohs(port));
|
||||
|
||||
return ok;
|
||||
|
Loading…
Reference in New Issue
Block a user