fs: returns EBADF on negative file descriptor (#1391)
This changes file descriptors from uint32 to int32 and the corresponding file table to reject negative values. This ensures invalid values aren't mistaken for very large descriptor entries, which can use a lot of memory as the table implementation isn't designed to be sparse. See https://pubs.opengroup.org/onlinepubs/9699919799/functions/dirfd.html#tag_16_90 Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -142,7 +142,7 @@ func (m *ModuleInstance) setExitCode(exitCode uint32, flag exitCodeFlag) bool {
|
||||
// Multiple calls to this function is safe.
|
||||
func (m *ModuleInstance) ensureResourcesClosed(ctx context.Context) (err error) {
|
||||
if sysCtx := m.Sys; sysCtx != nil { // nil if from HostModuleBuilder
|
||||
if err = sysCtx.FS().Close(ctx); err != nil {
|
||||
if err = sysCtx.FS().Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Sys = nil
|
||||
|
||||
Reference in New Issue
Block a user