This forum has been archived. All content is frozen. Please use KDE Discuss instead.

KTorrent 3.1.2 byte order bug

Tags: None
(comma "," separated)
heckerme
Registered Member
Posts
3
Karma
0

KTorrent 3.1.2 byte order bug

Thu Jan 08, 2009 4:13 am
Not sure whether this has been fixed in newer version. But here is the bug.

void UTPex::encode(…) // UTPEX.CPP
{
.
.
// Use KDE API to get an IP in Network Byte Order.
// WriteUint32 swap the byte order again!!!
WriteUint32(buf,size,addr.ipAddress().IPv4Addr());
.
.
}
void WriteUint32(Uint8* buf,Uint32 off,Uint32 val) //FUNCTIONS.CPP
{
// swap the byte order
buf[off + 0] = (Uint8) ((val & 0xFF000000) >> 24);
buf[off + 1] = (Uint8) ((val & 0x00FF0000) >> 16);
buf[off + 2] = (Uint8) ((val & 0x0000FF00) >> 8);
buf[off + 3] = (Uint8) (val & 0x000000FF);
}
George
Moderator
Posts
5421
Karma
1

Thu Jan 08, 2009 10:29 am
I'm not sure looking at the documentation and the implementation, seeing that it returns quint32 from an internal array.

http://api.kde.org/4.x-api/kdelibs-apid ... 4c462300ba

We need to figure out if KIpAddress stores the address in network or host byte order internally.
heckerme
Registered Member
Posts
3
Karma
0

Thu Jan 08, 2009 4:02 pm
I am quite sure the KDE lib return IP in network byte order. You can write a testing program to try it out.




George wrote:I'm not sure looking at the documentation and the implementation, seeing that it returns quint32 from an internal array.

http://api.kde.org/4.x-api/kdelibs-apid ... 4c462300ba

We need to figure out if KIpAddress stores the address in network or host byte order internally.
George
Moderator
Posts
5421
Karma
1

Thu Jan 08, 2009 6:45 pm
I have, and you are right, will fix it later today
heckerme
Registered Member
Posts
3
Karma
0

Sat Jan 10, 2009 3:52 am
Great:)


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar