internal/wayland: check pathname size
All checks were successful
Test / Create distribution (push) Successful in 26s
Test / Sandbox (push) Successful in 39s
Test / Sandbox (race detector) (push) Successful in 39s
Test / Hakurei (push) Successful in 43s
Test / Hakurei (race detector) (push) Successful in 43s
Test / Hpkg (push) Successful in 41s
Test / Flake checks (push) Successful in 1m22s
All checks were successful
Test / Create distribution (push) Successful in 26s
Test / Sandbox (push) Successful in 39s
Test / Sandbox (race detector) (push) Successful in 39s
Test / Hakurei (push) Successful in 43s
Test / Hakurei (race detector) (push) Successful in 43s
Test / Hpkg (push) Successful in 41s
Test / Flake checks (push) Successful in 1m22s
This avoids passing a truncated pathname to the kernel. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -12,8 +12,8 @@ package wayland
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -134,8 +134,11 @@ func securityContextBind(
|
||||
appID, instanceID string,
|
||||
closeFd int,
|
||||
) error {
|
||||
if hasNull(appID) || hasNull(instanceID) {
|
||||
return syscall.EINVAL
|
||||
if hasNull(socketPath) || hasNull(appID) || hasNull(instanceID) {
|
||||
return &Error{Cause: RBind, Path: socketPath, Errno: errors.New("argument contains NUL character")}
|
||||
}
|
||||
if !C.hakurei_is_valid_size_sun_path(C.size_t(len(socketPath))) {
|
||||
return &Error{Cause: RBind, Path: socketPath, Errno: errors.New("socket pathname too long")}
|
||||
}
|
||||
|
||||
var e Error
|
||||
|
||||
Reference in New Issue
Block a user