@@ -134,6 +134,22 @@ func TestReadFile(t *testing.T) {
134
134
}
135
135
}
136
136
137
+ damageStringLen := func (t * testing.T , name string ) {
138
+ data , err := os .ReadFile (name )
139
+ if err != nil {
140
+ t .Fatal (err )
141
+ }
142
+ i := bytes .Index (data , []byte ("\xff Go buildinf:" ))
143
+ if i < 0 {
144
+ t .Fatal ("Go buildinf not found" )
145
+ }
146
+ verLen := data [i + 32 :]
147
+ binary .PutUvarint (verLen , 16 << 40 ) // 16TB ought to be enough for anyone.
148
+ if err := os .WriteFile (name , data , 0666 ); err != nil {
149
+ t .Fatal (err )
150
+ }
151
+ }
152
+
137
153
goVersionRe := regexp .MustCompile ("(?m)^go\t .*\n " )
138
154
buildRe := regexp .MustCompile ("(?m)^build\t .*\n " )
139
155
cleanOutputForComparison := func (got string ) string {
@@ -193,6 +209,15 @@ func TestReadFile(t *testing.T) {
193
209
},
194
210
wantErr : "not a Go executable" ,
195
211
},
212
+ {
213
+ name : "invalid_str_len" ,
214
+ build : func (t * testing.T , goos , goarch , buildmode string ) string {
215
+ name := buildWithModules (t , goos , goarch , buildmode )
216
+ damageStringLen (t , name )
217
+ return name
218
+ },
219
+ wantErr : "not a Go executable" ,
220
+ },
196
221
{
197
222
name : "valid_gopath" ,
198
223
build : buildWithGOPATH ,
0 commit comments