mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-19 11:54:22 -04: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
1 changed files with 11 additions and 3 deletions
|
@ -587,11 +587,19 @@ bool SetTlvIpAddrPortV4(void *data, uint32_t size, uint32_t *offset,
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
ok &= SetTlvBase(data, tlvend, offset, type, tlvsize);
|
ok &= SetTlvBase(data, tlvend, offset, type, tlvsize);
|
||||||
|
|
||||||
/* now add the data .... (its already in network order) - so flip */
|
sockaddr_in addr = *out;
|
||||||
uint32_t ipaddr = out->sin_addr.s_addr;
|
//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));
|
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));
|
ok &= setRawUInt16(data, tlvend, offset, ntohs(port));
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue