diff --git a/c-cpp-rules.json b/c-cpp-rules.json index 2653b68..048964a 100644 --- a/c-cpp-rules.json +++ b/c-cpp-rules.json @@ -1333,7 +1333,7 @@ "level": "warning", "comment": "用 == 或 != 判断浮点数(float、double、long double)是否相等会得到非预期的结果。", "tag": "expression", - "reference": "CWE-1025,MISRA C 2004 13.3,MISRA C++ 2008 6-2-2" + "reference": "CWE-1077,MISRA C 2004 13.3,MISRA C++ 2008 6-2-2" }, "ID_successiveComparison": { "checkPoint": "比较运算不可作为另一个比较运算的直接子表达式", @@ -3647,7 +3647,7 @@ "ID_bufferOverflow": { "checkPoint": "避免缓冲区溢出", "level": "warning", - "comment": "缓冲区溢出是一种高度危险的安全漏洞,广泛存在于各类软件系统中。", + "comment": "缓冲区溢出是一种高度危险的安全漏洞,而且广泛存在于各类软件系统中。", "tag": "buffer", "related": "ID_arrayIndexOverflow,ID_unsafeStringFunction", "reference": "CWE-119,CWE-125,CWE-787,CWE-788" diff --git a/c-cpp-rules.md b/c-cpp-rules.md index 8a8d383..3c8b4f2 100644 --- a/c-cpp-rules.md +++ b/c-cpp-rules.md @@ -4912,8 +4912,8 @@ namespace NS { void foo(short); } -using namespace NS; // Non-compliant -using namespace std; // Non-compliant +using namespace NS; // Non-compliant, a using-directive in a header +using namespace std; // Non-compliant, a using-directive in a header ``` 下例展示的问题是头文件不同的包含顺序竟导致同一函数产生了不同的行为: ``` @@ -5343,8 +5343,8 @@ void foo() { 建议用 using 声明 代替 using 指令: ``` void foo() { - using myspace::type; // Compliant - using myspace::some_fun; // Compliant + using myspace::type; // Compliant, using-declaration + using myspace::some_fun; // Compliant, using-declaration type x; some_fun(x); @@ -18431,12 +18431,12 @@ if (feq(f, 0.1)) { // Compliant cout << "OK"; } ``` -在实际代码中,对于 float、double、long double 等不同的浮点类型,可以分别使用在标准头文件 float.h 中定义的宏 FLT\_EPSILON、DBL\_EPSILON、LDBL\_EPSILON 作为 e 的值,在 C\+\+ 代码中,也可以使用标准模板库提供的 std::numeric\_limits\::epsilon(),其中 T 为浮点类型。 +在实际代码中,对于 float、double、long double 等不同的浮点类型,可以分别使用在标准头文件 float.h 中定义的宏 FLT\_EPSILON、DBL\_EPSILON、LDBL\_EPSILON 作为 e 的值,在 C\+\+ 代码中,也可以使用标准模板库提供的 std::numeric\_limits\::epsilon(),其中 T 为指定的浮点类型。

#### 参考 -CWE-1025 +CWE-1077 MISRA C 2004 13.3 MISRA C++ 2008 6-2-2
@@ -21675,7 +21675,7 @@ ID_bufferOverflow       :fire: buffer warning
-缓冲区溢出是一种高度危险的安全漏洞,广泛存在于各类软件系统中。 +缓冲区溢出是一种高度危险的安全漏洞,而且广泛存在于各类软件系统中。 “缓冲区(buffer)”的本意是指内存等高速设备上的区域,程序在这种区域内接收或处理数据,之后再一并输出到网络或磁盘等低速环境,起到提高效率的作用,故称缓冲区。连续的内存区域均可称为缓冲区,在 C/C\+\+ 语言中对应数组等结构。