运算处理R-1-6-19强制

禁止字符串函数操作导致目标存储空间越界

字符串函数操作导致目标存储空间越界
test.c
1#include <string.h>
2#include <stdio.h>
3
4void foo(void)
5{
6 char str[2] = {0};
7 strncpy(str, "foo", 3);
禁止字符串函数操作导致目标存储空间越界 [gjb8114-r-1-6-19]
8 strncat(str, "()", 2);
9}
字符串函数操作导致目标存储空间越界
test.c
1#include <string.h>
2#include <stdio.h>
3
4void foo(void)
5{
6 char str[6] = {0};
7 strncpy(str, "foo", 3);
8 strncat(str, "()", 2);
9}