diff options
author | rsuen | 2009-04-24 22:38:00 +0000 |
---|---|---|
committer | rsuen | 2009-04-24 22:38:00 +0000 |
commit | 64653350b32ef29c46296bac0d693f15c18fdd71 (patch) | |
tree | 0971f3f09caf37fed5e4e4867117d1733990496b /protocols/bundles/org.eclipse.ecf.protocol.bittorrent | |
parent | eac59717335a57b2c018e636586db09017cb7dc0 (diff) | |
download | org.eclipse.ecf-64653350b32ef29c46296bac0d693f15c18fdd71.tar.gz org.eclipse.ecf-64653350b32ef29c46296bac0d693f15c18fdd71.tar.xz org.eclipse.ecf-64653350b32ef29c46296bac0d693f15c18fdd71.zip |
Bug 265174 Bittorrent client Encoder class does not encode integer properly
Diffstat (limited to 'protocols/bundles/org.eclipse.ecf.protocol.bittorrent')
-rw-r--r-- | protocols/bundles/org.eclipse.ecf.protocol.bittorrent/src/org/eclipse/ecf/protocol/bittorrent/internal/encode/Encode.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/protocols/bundles/org.eclipse.ecf.protocol.bittorrent/src/org/eclipse/ecf/protocol/bittorrent/internal/encode/Encode.java b/protocols/bundles/org.eclipse.ecf.protocol.bittorrent/src/org/eclipse/ecf/protocol/bittorrent/internal/encode/Encode.java index 0ce389eb7..7a4fe16d9 100644 --- a/protocols/bundles/org.eclipse.ecf.protocol.bittorrent/src/org/eclipse/ecf/protocol/bittorrent/internal/encode/Encode.java +++ b/protocols/bundles/org.eclipse.ecf.protocol.bittorrent/src/org/eclipse/ecf/protocol/bittorrent/internal/encode/Encode.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Remy Suen, Composent Inc., and others. + * Copyright (c) 2006, 2009 Remy Suen, Composent Inc., and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * Remy Suen <remy.suen@gmail.com> - initial API and implementation + * Matthew Jucius <matthew@jucius.com> - Bug 265174 ******************************************************************************/ package org.eclipse.ecf.protocol.bittorrent.internal.encode; @@ -48,10 +49,10 @@ public final class Encode { */ public static void putIntegerAsFourBytes(byte[] haveArray, int number, int index) { - haveArray[index] = number > 16777215 ? (byte) (number / 16777216) : 0; - haveArray[index + 1] = number > 65536 ? (byte) (number / 65536) : 0; - haveArray[index + 2] = number > 255 ? (byte) (number / 256) : 0; - haveArray[index + 3] = (byte) (number % 256); + haveArray[index] = (byte) (number >>> 24); + haveArray[index + 1] = (byte) (number >>> 16); + haveArray[index + 2] = (byte) (number >>> 8); + haveArray[index + 3] = (byte) number; } /** |