mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
fix all ql/use-string-compare
This commit is contained in:
@@ -872,7 +872,7 @@ class FormatLiteral extends Literal {
|
||||
|
||||
private Type getConversionType1(int n) {
|
||||
exists(string cnv | cnv = this.getConversionChar(n) |
|
||||
cnv.regexpMatch("d|i") and
|
||||
cnv = ["d", "i"] and
|
||||
result = this.getIntegralConversion(n) and
|
||||
not result.getUnderlyingType().(IntegralType).isExplicitlySigned() and
|
||||
not result.getUnderlyingType().(IntegralType).isExplicitlyUnsigned()
|
||||
@@ -912,7 +912,7 @@ class FormatLiteral extends Literal {
|
||||
|
||||
private Type getConversionType2(int n) {
|
||||
exists(string cnv | cnv = this.getConversionChar(n) |
|
||||
cnv.regexpMatch("o|u|x|X") and
|
||||
cnv = ["o", "u", "x", "X"] and
|
||||
result = this.getIntegralConversion(n) and
|
||||
result.getUnderlyingType().(IntegralType).isUnsigned()
|
||||
)
|
||||
@@ -920,7 +920,7 @@ class FormatLiteral extends Literal {
|
||||
|
||||
private Type getConversionType3(int n) {
|
||||
exists(string cnv | cnv = this.getConversionChar(n) |
|
||||
cnv.regexpMatch("a|A|e|E|f|F|g|G") and result = this.getFloatingPointConversion(n)
|
||||
cnv = ["a", "A", "e", "E", "f", "F", "g", "G"] and result = this.getFloatingPointConversion(n)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ where
|
||||
// unfortunately cannot use numeric value here because // O_CREAT is defined differently on different OSes:
|
||||
// https://github.com/red/red/blob/92feb0c0d5f91e087ab35fface6906afbf99b603/runtime/definitions.reds#L477-L491
|
||||
// this may introduce false negatives
|
||||
fctmp.getArgument(1).(BitwiseOrExpr).getAChild*().getValueText().matches("O\\_CREAT") or
|
||||
fctmp.getArgument(1).(BitwiseOrExpr).getAChild*().getValueText() = "O_CREAT" or
|
||||
fctmp.getArgument(1).getValueText().matches("%O_CREAT%")
|
||||
) and
|
||||
fctmp.getNumberOfArguments() = 2 and
|
||||
|
||||
@@ -13,7 +13,7 @@ import cpp
|
||||
|
||||
from Function f
|
||||
where
|
||||
f.getName().regexpMatch("atof|atoi|atol") and
|
||||
f.getName() = ["atof", "atoi", "atol"] and
|
||||
f.getFile().getAbsolutePath().matches("%stdlib.h")
|
||||
select f.getACallToThisFunction(),
|
||||
"AV Rule 23: The library functions atof, atoi and atol from library <stdlib.h> shall not be used."
|
||||
|
||||
@@ -13,7 +13,7 @@ import cpp
|
||||
|
||||
from Function f
|
||||
where
|
||||
f.getName().regexpMatch("abort|exit|getenv|system") and
|
||||
f.getName() = ["abort", "exit", "getenv", "system"] and
|
||||
f.getFile().getAbsolutePath().matches("%stdlib.h")
|
||||
select f.getACallToThisFunction(),
|
||||
"The library functions abort, exit, getenv and system from library <stdlib.h> should not be used."
|
||||
|
||||
Reference in New Issue
Block a user