Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 83b4070

Browse files
author
Benjamin Muskalla
committed
Fix bug to accept bulk data for char/byte arrays
1 parent 281f254 commit 83b4070

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

java/ql/src/utils/model-generator/CaptureSummaryModels.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ predicate isRelevantType(Type t) {
129129
not t instanceof PrimitiveType and
130130
not t instanceof BoxedType and
131131
not t.(RefType).hasQualifiedName("java.math", "BigInteger") and
132-
not t.(Array).getElementType() instanceof PrimitiveType and
133-
not t.(Array).getElementType().(PrimitiveType).getName().regexpMatch("byte|char") and
132+
(
133+
not t.(Array).getElementType() instanceof PrimitiveType or
134+
t.(Array).getElementType().(PrimitiveType).getName().regexpMatch("byte|char")
135+
) and
134136
not t.(Array).getElementType() instanceof BoxedType and
135137
not t.(CollectionType).getElementType() instanceof BoxedType
136138
}

java/ql/test/utils/model-generator/CaptureSummaryModels.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,7 @@
3232
| p;ParamFlow;true;returnsInput;(String);;Argument[0];ReturnValue;taint; |
3333
| p;ParamFlow;true;writeChunked;(byte[],OutputStream);;ArrayElement of Argument[0];Argument[1];taint; |
3434
| p;Pojo;false;fillIn;(List);;Argument[-1];Element of Argument[0];taint; |
35+
| p;Pojo;false;getByteArray;();;Argument[-1];ReturnValue;taint; |
36+
| p;Pojo;false;getCharArray;();;Argument[-1];ReturnValue;taint; |
3537
| p;Pojo;false;getValue;();;Argument[-1];ReturnValue;taint; |
3638
| p;Pojo;false;setValue;(String);;Argument[0];Argument[-1];taint; |

java/ql/test/utils/model-generator/p/Pojo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,17 @@ public int[] getPrimitiveArray() {
4848
}
4949

5050
public char[] getCharArray() {
51-
return Character.toChars(intValue);
51+
return new char[] { (char) intValue };
5252
}
5353

5454
public byte[] getByteArray() {
5555
return new byte[] { (byte) intValue };
5656
}
5757

58+
public float[] getFloatArray() {
59+
return new float[] { (float) intValue };
60+
}
61+
5862
public Integer[] getBoxedArray() {
5963
return new Integer[] { Integer.valueOf(intValue) };
6064
}

0 commit comments

Comments
 (0)