mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
CPP: Move the AV Rule 97 test.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
| jsf97.cpp:6:12:6:15 | bad1 | Raw arrays should not be used in interfaces. A container class should be used instead. |
|
||||
| jsf97.cpp:11:12:11:15 | bad2 | Raw arrays should not be used in interfaces. A container class should be used instead. |
|
||||
| jsf97.cpp:16:12:16:15 | bad3 | Raw arrays should not be used in interfaces. A container class should be used instead. |
|
||||
| jsf97.cpp:21:12:21:15 | bad4 | Raw arrays should not be used in interfaces. A container class should be used instead. |
|
||||
| jsf97.cpp:40:13:40:23 | bad_longjmp | Raw arrays should not be used in interfaces. A container class should be used instead. |
|
||||
@@ -0,0 +1 @@
|
||||
jsf/4.10 Classes/AV Rule 97.ql
|
||||
@@ -0,0 +1,62 @@
|
||||
typedef char chars[10];
|
||||
typedef int jmp_buf[16];
|
||||
|
||||
class C { public:
|
||||
|
||||
static int bad1(char xs[10])
|
||||
{
|
||||
return sizeof(xs);
|
||||
}
|
||||
|
||||
static int bad2(char xs[])
|
||||
{
|
||||
return sizeof(xs);
|
||||
}
|
||||
|
||||
static int bad3(chars xs)
|
||||
{
|
||||
return sizeof(xs);
|
||||
}
|
||||
|
||||
static int bad4(chars const xs)
|
||||
{
|
||||
return sizeof(xs);
|
||||
}
|
||||
|
||||
static int good1(char (&xs)[10])
|
||||
{
|
||||
return sizeof(xs);
|
||||
}
|
||||
|
||||
static int good2(chars& xs)
|
||||
{
|
||||
return sizeof(xs);
|
||||
}
|
||||
|
||||
static void good_longjmp(jmp_buf j)
|
||||
{
|
||||
}
|
||||
|
||||
static void bad_longjmp(int j[16])
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T, unsigned N>
|
||||
static unsigned array_size(T(&)[N])
|
||||
{
|
||||
return N;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void no_op(T&& arg)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
chars c;
|
||||
C::no_op(c);
|
||||
return C::array_size(c);
|
||||
}
|
||||
Reference in New Issue
Block a user