You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnstrlen((char*)&malloc); // expected-warning{{Argument to string length function is the address of the function 'malloc', which is not a null-terminated string}}
9
+
}
10
+
11
+
size_ttest_addr_label() {
12
+
lab:
13
+
returnstrlen((char*)&&lab); // expected-warning{{Argument to string length function is the address of the label 'lab', which is not a null-terminated string}}
14
+
}
15
+
16
+
size_ttest_init_compound(inti) {
17
+
charsrc1[6] = {1,2,3,4,5,6};
18
+
charsrc2[6] = {1,2,3,0,5,6};
19
+
switch (i) {
20
+
case1:
21
+
returnstrlen(src1); // expected-warning{{Terminating zero missing from string passed as 1st argument to string length function}}
22
+
case2:
23
+
returnstrlen(src1+1); // expected-warning{{Terminating zero missing from string}}
24
+
case3:
25
+
returnstrlen(src2);
26
+
case4:
27
+
returnstrlen(src2+4); // expected-warning{{Terminating zero missing from string}}
28
+
case5:
29
+
returnstrlen(src2+3);
30
+
}
31
+
src1[5] =0;
32
+
returnstrlen(src1);
33
+
}
34
+
35
+
size_ttest_init_literal(inti) {
36
+
charsrc1[] ="abcdef";
37
+
intl=strlen(src1);
38
+
src1[6] ='.';
39
+
src1[3] =0;
40
+
switch (i) {
41
+
case1:
42
+
returnstrlen(src1);
43
+
case2:
44
+
returnstrlen(src1+4); // expected-warning{{Terminating zero missing from string}}
45
+
}
46
+
returnl;
47
+
}
48
+
49
+
size_ttest_init_assign(inti, chara) {
50
+
charsrc[6];
51
+
src[1] ='1';
52
+
src[2] ='2';
53
+
src[4] ='4';
54
+
src[5] ='5';
55
+
56
+
switch (i) {
57
+
case0:
58
+
returnstrlen(src);
59
+
case1:
60
+
returnstrlen(src+1);
61
+
case2:
62
+
returnstrlen(src+2);
63
+
case3:
64
+
returnstrlen(src+3);
65
+
case4:
66
+
returnstrlen(src+4); // expected-warning{{Terminating zero missing from string}}
67
+
}
68
+
src[5] =a;
69
+
size_tl=strlen(src+4);
70
+
src[5] =0;
71
+
l+=strlen(src+4);
72
+
src[5] ='5';
73
+
returnl+strlen(src+4); // expected-warning{{Terminating zero missing from string}}
74
+
}
75
+
76
+
size_ttest_assign1() {
77
+
charstr1[5] = {'0','1','2','3','4'};
78
+
charstr2[5];
79
+
str2[0] =str1[0];
80
+
str2[1] =str1[1];
81
+
str2[4] =str1[4];
82
+
size_tl=strlen(str2);
83
+
returnl+strlen(str2+4); // expected-warning{{Terminating zero missing from string}}
84
+
}
85
+
86
+
size_ttest_assign2() {
87
+
charstr1[5] = {1,2,3,4,5};
88
+
charstr2[5];
89
+
str2[0] =str1[0];
90
+
str2[4] =str2[0];
91
+
returnstrlen(str2+4); // expected-warning{{Terminating zero missing from string}}
92
+
}
93
+
94
+
voidtest_ignore(char*dst) {
95
+
charstr1[5] = {1,2,3,4,5};
96
+
strncpy(dst, str1, 5);
97
+
strcpy(dst, str1); // expected-warning{{Terminating zero missing from string}}
98
+
}
99
+
100
+
size_ttest_malloc() {
101
+
char*buf= (char*)malloc(4);
102
+
if (!buf)
103
+
return0;
104
+
buf[3] ='a';
105
+
returnstrlen(buf);
106
+
}
107
+
108
+
externvoidf_ext(char*);
109
+
char*g_buf=0;
110
+
111
+
size_ttest_escape1() {
112
+
charbuf[4] = {1,2,3,4};
113
+
f_ext(buf);
114
+
returnstrlen(buf);
115
+
}
116
+
117
+
size_ttest_escape2(char*x) {
118
+
charbuf[4] = {1,2,3,4};
119
+
g_buf=buf;
120
+
f_ext(x);
121
+
returnstrlen(buf);
122
+
}
123
+
124
+
size_ttest_escape3() {
125
+
charbuf[4] = {1,2,3,4};
126
+
f_ext(buf+3);
127
+
returnstrlen(buf);
128
+
}
129
+
130
+
voidtest_str_fn(inti, char*dst) {
131
+
charbuf[] = {1, 2, 3};
132
+
switch (i) {
133
+
case1:
134
+
strcpy(buf, "aa"); // expected-warning{{Terminating zero missing from string}}
135
+
break;
136
+
case2:
137
+
strcpy(dst, buf); // expected-warning{{Terminating zero missing from string}}
138
+
break;
139
+
case3:
140
+
strncpy(buf, "aa", 3);
141
+
break;
142
+
case4:
143
+
strncpy(dst, buf, 3);
144
+
break;
145
+
case5:
146
+
strcat(buf, "aa"); // expected-warning{{Terminating zero missing from string}}
147
+
break;
148
+
case6:
149
+
strcat(dst, buf); // expected-warning{{Terminating zero missing from string}}
150
+
break;
151
+
case7:
152
+
strncat(buf, "aa", 3); // expected-warning{{Terminating zero missing from string}}
0 commit comments