From 0dedac637ff9f6f7a0556d42d90787584a4051da Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Mon, 9 Jul 2018 11:43:06 -0700 Subject: Trim all whitespace between interpreter and arg Multiple whitespace characters are allowed. This fixes Ubuntu's /usr/sbin/invoke-rc.d, which has trailing whitespace after the interpreter which we were treating as an arg. PiperOrigin-RevId: 203802278 Change-Id: I0a6cdb0af4b139cf8abb22fa70351fe3697a5c6b --- pkg/sentry/loader/interpreter.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/sentry/loader/interpreter.go b/pkg/sentry/loader/interpreter.go index 7249b8f30..54534952b 100644 --- a/pkg/sentry/loader/interpreter.go +++ b/pkg/sentry/loader/interpreter.go @@ -66,7 +66,7 @@ func parseInterpreterScript(ctx context.Context, filename string, f *fs.File, ar // Skip any whitespace before the interpeter. line = bytes.TrimLeft(line, " \t") - // Linux only looks for a space or tab delimiting the interpreter and + // Linux only looks for spaces or tabs delimiting the interpreter and // arg. // // execve(2): "On Linux, the entire string following the interpreter @@ -77,9 +77,7 @@ func parseInterpreterScript(ctx context.Context, filename string, f *fs.File, ar i = bytes.IndexAny(line, " \t") if i >= 0 { interp = line[:i] - if i+1 < len(line) { - arg = line[i+1:] - } + arg = bytes.TrimLeft(line[i:], " \t") } if string(interp) == "" { -- cgit v1.2.3