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

Skip to content

Commit 51e787b

Browse files
committed
Switching to looking for explicit declaration of unsigned char, to avoid cases where unsigned char is the default char width for char.
1 parent c4737c7 commit 51e787b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

cpp/ql/src/Security/CWE/CWE-704/WcharCharConversion.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ Type getABaseType(Type t) {
3737
class UnlikelyToBeAStringType extends Type {
3838
UnlikelyToBeAStringType() {
3939
exists(Type targ |
40-
targ.(CharType).isUnsigned() or
40+
// NOTE: not using CharType isUnsigned, but rather look for any explicitly declared unsigned
41+
// char types. Assuming these are used for buffers, not strings.
42+
targ.(CharType).getName().toLowerCase().matches(["unsigned%"]) or
4143
targ.getName().toLowerCase().matches(["uint8_t", "%byte%"])
4244
|
4345
getABaseType(this) = targ

0 commit comments

Comments
 (0)