File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -233,8 +233,16 @@ func OptCreateWithCloseOnUnload(b bool) CreateOpt {
233
233
}
234
234
}
235
235
236
+ var errDescriptorCapacityNotSupported = errors .New ("descriptor capacity not supported" )
237
+
236
238
// createContainer creates a new SIF container file in rw, according to opts.
237
239
func createContainer (rw ReadWriter , co createOpts ) (* FileImage , error ) {
240
+ // The supported number of descriptors is limited by the unsigned 32-bit ID field in each
241
+ // rawDescriptor.
242
+ if co .descriptorCapacity >= math .MaxUint32 {
243
+ return nil , errDescriptorCapacityNotSupported
244
+ }
245
+
238
246
rds := make ([]rawDescriptor , co .descriptorCapacity )
239
247
rdsSize := int64 (binary .Size (rds ))
240
248
Original file line number Diff line number Diff line change @@ -186,6 +186,13 @@ func TestCreateContainerAtPath(t *testing.T) {
186
186
opts []CreateOpt
187
187
wantErr error
188
188
}{
189
+ {
190
+ name : "ErrDescriptorCapacityNotSupported" ,
191
+ opts : []CreateOpt {
192
+ OptCreateWithDescriptorCapacity (math .MaxUint32 ),
193
+ },
194
+ wantErr : errDescriptorCapacityNotSupported ,
195
+ },
189
196
{
190
197
name : "ErrInsufficientCapacity" ,
191
198
opts : []CreateOpt {
You can’t perform that action at this time.
0 commit comments