Skip to content

Commit

Permalink
fix: check error on normalizeCallerLoadedSource (#7451)
Browse files Browse the repository at this point in the history
`normalizeCallerLoadedSource` function can segfault if `withContextDirectory` returns an error, as we do not check for the returned error on the `withContextDirectory`.

The following dagql calls can be executed: on the `dagger init`, for example, the `withName` gets called on my tests, and trigger the segfault.

It is currently never triggered, as there are two potential edge cases in which we return an error on `withContextDirectory`:
1. when the modulesourcekind is not local
2. when we fail to load the dir

Signed-off-by: grouville <guillaume@dagger.io>
  • Loading branch information
grouville committed May 23, 2024
1 parent 417743d commit 643aa61
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/schema/modulesource.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,9 @@ func (s *moduleSchema) normalizeCallerLoadedSource(
},
},
)
if err != nil {
return inst, fmt.Errorf("failed to load the context directory: %w", err)
}

if src.WithName != "" {
err = s.dag.Select(ctx, inst, &inst,
Expand Down

0 comments on commit 643aa61

Please sign in to comment.