Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 261574 - Bittorrent client Encoder class does not encode integer properly
Summary: Bittorrent client Encoder class does not encode integer properly
Status: RESOLVED FIXED
Alias: None
Product: ECF
Classification: RT
Component: ecf.protocols (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 3.0.0M7   Edit
Assignee: Remy Suen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-19 19:09 EST by Matthew Jucius CLA
Modified: 2009-04-24 18:37 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (1.18 KB, patch)
2009-01-19 19:12 EST, Matthew Jucius CLA
remy.suen: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Jucius CLA 2009-01-19 19:09:05 EST
Build ID: M20080911-1700

Steps To Reproduce:
The class org.eclipse.ecf.protocol.bittorrent.internal.encode.Encode contains the static method:

putIntegerAsFourBytes(byte[] haveArray, int number, int index)

Create a class to call this method and run the following code:

    byte[] data = new byte[4];
    Encode.putIntegerAsFourBytes(data, 64 * 1024, 0);
    for (int i = 0; i < data.length; i++) {
        System.out.print(data[i] + " ");
    }

With the current implementation the output is:
    0 0 0 0

The output should be:
    0 1 0 0

More information:
This bug causes incompatibilities (including data corruption) with clients that rely on the Request message specifying the correct offset.
Comment 1 Matthew Jucius CLA 2009-01-19 19:12:17 EST
Created attachment 123018 [details]
Proposed patch

This code is a bit clearer in what it does than the original.
Comment 2 Scott Lewis CLA 2009-01-23 16:41:45 EST
Assigning to Remy for review/application of patch.
Comment 3 Scott Lewis CLA 2009-04-23 20:13:00 EDT
Seems like this could be fixed quickly/easily.  Remy if this is incorrect please advise.
Comment 4 Remy Suen CLA 2009-04-24 18:37:38 EDT
Fix released to HEAD. Thanks for the patch, Matthew.