Skip to content

Commit 72ca6b8

Browse files
committed
Add isSigned to IntegerParsers
1 parent c796cba commit 72ca6b8

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

go/ql/lib/semmle/go/frameworks/Stdlib.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ module IntegerParser {
117117
* input is 0 then it means the bit size of `int` and `uint`.
118118
*/
119119
FunctionInput getTargetBitSizeInput() { none() }
120+
121+
/** Gets whether the function is for parsing signed or unsigned integers. */
122+
boolean isSigned() { none() }
120123
}
121124
}
122125

go/ql/lib/semmle/go/frameworks/stdlib/Strconv.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@ module Strconv {
1111
Atoi() { this.hasQualifiedName("strconv", "Atoi") }
1212

1313
override int getTargetBitSize() { result = 0 }
14+
15+
override boolean isSigned() { result = true }
1416
}
1517

1618
/** The `ParseInt` function. */
1719
class ParseInt extends IntegerParser::Range {
1820
ParseInt() { this.hasQualifiedName("strconv", "ParseInt") }
1921

2022
override FunctionInput getTargetBitSizeInput() { result.isParameter(2) }
23+
24+
override boolean isSigned() { result = true }
2125
}
2226

2327
/** The `ParseUint` function. */
2428
class ParseUint extends IntegerParser::Range {
2529
ParseUint() { this.hasQualifiedName("strconv", "ParseUint") }
2630

2731
override FunctionInput getTargetBitSizeInput() { result.isParameter(2) }
32+
33+
override boolean isSigned() { result = false }
2834
}
2935

3036
/**

0 commit comments

Comments
 (0)