Skip to content
Permalink
Browse files
[JENKINS-7618] fixing bad integer parsing
  • Loading branch information
Rob Petti committed Jun 23, 2011
1 parent 0216bfc commit 3e159833ed2fde3682f68a48eb8620a7ecaaf0a2
Showing with 9 additions and 3 deletions.
  1. +3 −3 src/main/java/hudson/plugins/perforce/PerforceSCMHelper.java
  2. +6 −0 src/test/java/hudson/plugins/perforce/PerforceSCMHelperTest.java
@@ -78,10 +78,10 @@ public String getWorkspacePath() {

}

static private int readInt(byte[] bytes, int offset){
static public int readInt(byte[] bytes, int offset){
int result=0;
for (int i=offset; i<offset+4; i++) {
result += (int) bytes[i] << (8*(i-offset));
result += (int) (bytes[i]&0xff) << (8*(i-offset));
}
return result;
}
@@ -120,7 +120,7 @@ static private int readInt(byte[] bytes, int offset){
}

static private String readPythonString(byte[] bytes, int offset){
int length = readInt(bytes, offset);
int length = (int)readInt(bytes, offset);
String result = new String(bytes, offset+4, length);
return result;
}
@@ -78,4 +78,10 @@ public void testWhereParser() {
assertEquals("/home/rpetti/workspace/Install/trunk/Installers/build.properties", map.getFilesystemPath());
}

public void testReadIntNegativeByte() {
byte test[] = {(byte)-106,(byte)0,(byte)0,(byte)0};
int result = PerforceSCMHelper.readInt(test, 0);
assertEquals(150,result);
}

}

0 comments on commit 3e15983

Please sign in to comment.