Skip to content

Commit edd0302

Browse files
committed
fix the casing in the alert-message of cpp/unclear-array-index-validation
1 parent 9e4843d commit edd0302

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cpp/ql/src/Security/CWE/CWE-129/ImproperArrayIndexValidation.ql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ class ImproperArrayIndexValidationConfig extends TaintTracking::Configuration {
116116
}
117117
}
118118

119+
/** Gets `str` where the first letter has been lowercased. */
120+
bindingset[str]
121+
string lowerFirst(string str) { result = str.prefix(1).toLowerCase() + str.suffix(1) }
122+
119123
from
120124
ImproperArrayIndexValidationConfig conf, DataFlow::PathNode source, DataFlow::PathNode sink,
121125
string sourceType
@@ -124,4 +128,4 @@ where
124128
isFlowSource(source.getNode(), sourceType)
125129
select sink.getNode(), source, sink,
126130
"An array indexing expression depends on a $@ that might be outside the bounds of the array.",
127-
source.getNode(), sourceType
131+
source.getNode(), lowerFirst(sourceType)

cpp/ql/test/query-tests/Security/CWE/CWE-129/SAMATE/ImproperArrayIndexValidation/ImproperArrayIndexValidation.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ nodes
55
| CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_01.c:52:20:52:23 | data | semmle.label | data |
66
subpaths
77
#select
8-
| CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_01.c:52:20:52:23 | data | CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_01.c:30:19:30:29 | fgets output argument | CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_01.c:52:20:52:23 | data | An array indexing expression depends on a $@ that might be outside the bounds of the array. | CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_01.c:30:19:30:29 | fgets output argument | String read by fgets |
8+
| CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_01.c:52:20:52:23 | data | CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_01.c:30:19:30:29 | fgets output argument | CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_01.c:52:20:52:23 | data | An array indexing expression depends on a $@ that might be outside the bounds of the array. | CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_01.c:30:19:30:29 | fgets output argument | string read by fgets |

0 commit comments

Comments
 (0)