mirror of
https://github.com/github/codeql.git
synced 2026-01-29 14:23:03 +01:00
Merge pull request #718 from owen-mc/fix-incorrect-integer-conversion-for-type-assertions
Integer conversion should ignore type assertions
This commit is contained in:
@@ -110,6 +110,7 @@ class ConversionWithoutBoundsCheckConfig extends TaintTracking::Configuration {
|
||||
* a common pattern to serialise `byte(v)`, `byte(v >> 8)`, and so on.
|
||||
*/
|
||||
predicate isSink(DataFlow::TypeCastNode sink, int bitSize) {
|
||||
sink.asExpr() instanceof ConversionExpr and
|
||||
exists(IntegerType integerType | sink.getResultType().getUnderlyingType() = integerType |
|
||||
bitSize = integerType.getSize()
|
||||
or
|
||||
|
||||
@@ -409,3 +409,13 @@ func parsePositiveInt2(value string) (int, error) {
|
||||
}
|
||||
return int(i64), nil
|
||||
}
|
||||
|
||||
func typeAssertion(s string) {
|
||||
n, err := strconv.ParseInt(s, 10, 0)
|
||||
if err == nil {
|
||||
var itf interface{} = n
|
||||
i32 := itf.(int32)
|
||||
println(i32)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user