Skip to content

Commit

Permalink
Unix rtlib: Fix exec() to support spaces in executable path
Browse files Browse the repository at this point in the history
fb_hGetShortPath() escaped spaces as "\ " in paths containing spaces,
which is bad here because the path is passed to execvp() which is not
a shell but just expects the raw file name.

On top of that, the fb_hConvertPath() done afterwards converts \ to /,
so spaces were turned into "/ ", resulting in a completely different path
than what was given to exec().

This fixes the former, so the second won't kick in in this case either
anymore, but the \ => / conversion in general is not removed here. That's
another discussion...
  • Loading branch information
dkl committed Jul 5, 2016
1 parent 28b15c3 commit af261fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Version 1.06.0
- boolean initializer values for global or static variables were not emitted properly
- Compiler crash after reporting error about REDIM on a fixed-size array field
- #827: Using the GNU gold linker (instead of ld.bfd) resulted in broken binaries due to fbextra.x, which fbc uses with ld.bfd to discard the objinfo .fbctinf sections, but is not supported by gold. Now when gold is detected, fbextra.x won't be used anymore, in order to get working binaries.
- exec() on Linux & co was broken with regards to spaces in the executable path. Spaces were converted to "\ " and then to "/ ", resulting in a different path than given.


Version 1.05.0
Expand Down
3 changes: 2 additions & 1 deletion src/rtlib/unix/sys_execex.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ FBCALL int fb_ExecEx( FBSTRING *program, FBSTRING *args, int do_fork )
return -1;
}

fb_hGetShortPath( program->data, buffer, MAX_PATH );
strncpy( buffer, program->data, sizeof( buffer ) );
buffer[sizeof( buffer ) - 1] = 0;

fb_hConvertPath( buffer );

Expand Down

0 comments on commit af261fd

Please sign in to comment.