diff options
author | Ron Yorston <rmy@pobox.com> | 2018-12-08 08:50:37 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-12-08 09:01:15 +0000 |
commit | 88b782fb0e7ad26c8363eda5c850e5eba6acb445 (patch) | |
tree | 723937017d4e60574dcd284a91bacc82c7a166ac | |
parent | 1e68bd2ca699f3388ae149f986b61aa6d105550c (diff) | |
download | busybox-w32-88b782fb0e7ad26c8363eda5c850e5eba6acb445.tar.gz busybox-w32-88b782fb0e7ad26c8363eda5c850e5eba6acb445.tar.bz2 busybox-w32-88b782fb0e7ad26c8363eda5c850e5eba6acb445.zip |
win32: allow execution of empty batch file to succeed
Microsoft Windows' spawnve returns ERROR_BAD_EXE_FORMAT when passed
an empty batch file.
Work around this by skipping spawnve and returning success.
-rw-r--r-- | win32/process.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/win32/process.c b/win32/process.c index fda38318a..f059bee18 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -237,6 +237,13 @@ spawnveq(int mode, const char *path, char *const *argv, char *const *env) | |||
237 | if (*s == '/') | 237 | if (*s == '/') |
238 | *s = '\\'; | 238 | *s = '\\'; |
239 | } | 239 | } |
240 | |||
241 | /* Another special case: spawnve returns ENOEXEC when passed an | ||
242 | * empty batch file. Pretend it worked. */ | ||
243 | if (st.st_size == 0) { | ||
244 | ret = 0; | ||
245 | goto done; | ||
246 | } | ||
240 | } | 247 | } |
241 | 248 | ||
242 | /* | 249 | /* |
@@ -250,6 +257,7 @@ spawnveq(int mode, const char *path, char *const *argv, char *const *env) | |||
250 | 257 | ||
251 | ret = spawnve(mode, new_path ? new_path : path, new_argv, env); | 258 | ret = spawnve(mode, new_path ? new_path : path, new_argv, env); |
252 | 259 | ||
260 | done: | ||
253 | for (i = 0;i < argc;i++) | 261 | for (i = 0;i < argc;i++) |
254 | if (new_argv[i] != argv[i]) | 262 | if (new_argv[i] != argv[i]) |
255 | free(new_argv[i]); | 263 | free(new_argv[i]); |