diff options
-rw-r--r-- | archival/ar.c | 4 | ||||
-rw-r--r-- | archival/cpio.c | 14 |
2 files changed, 9 insertions, 9 deletions
diff --git a/archival/ar.c b/archival/ar.c index 1b43502ca..4f21bf82f 100644 --- a/archival/ar.c +++ b/archival/ar.c | |||
@@ -49,7 +49,7 @@ int ar_main(int argc UNUSED_PARAM, char **argv) | |||
49 | archive_handle = init_handle(); | 49 | archive_handle = init_handle(); |
50 | 50 | ||
51 | /* Prepend '-' to the first argument if required */ | 51 | /* Prepend '-' to the first argument if required */ |
52 | opt_complementary = "--:p:t:x:-1:p--tx:t--px:x--pt"; | 52 | opt_complementary = "--:-1:p:t:x:-1:p--tx:t--px:x--pt"; |
53 | opt = getopt32(argv, "ptxovcr"); | 53 | opt = getopt32(argv, "ptxovcr"); |
54 | argv += optind; | 54 | argv += optind; |
55 | 55 | ||
@@ -75,7 +75,7 @@ int ar_main(int argc UNUSED_PARAM, char **argv) | |||
75 | bb_error_msg_and_die(msg_unsupported_err, "insertion"); | 75 | bb_error_msg_and_die(msg_unsupported_err, "insertion"); |
76 | } | 76 | } |
77 | 77 | ||
78 | archive_handle->src_fd = xopen(argv[optind++], O_RDONLY); | 78 | archive_handle->src_fd = xopen(*argv++, O_RDONLY); |
79 | 79 | ||
80 | while (*argv) { | 80 | while (*argv) { |
81 | archive_handle->filter = filter_accept_list; | 81 | archive_handle->filter = filter_accept_list; |
diff --git a/archival/cpio.c b/archival/cpio.c index f139f3130..5c16678e4 100644 --- a/archival/cpio.c +++ b/archival/cpio.c | |||
@@ -307,16 +307,17 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
307 | opt = getopt32(argv, OPTION_STR, &cpio_filename); | 307 | opt = getopt32(argv, OPTION_STR, &cpio_filename); |
308 | #else | 308 | #else |
309 | opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt); | 309 | opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt); |
310 | argv += optind; | ||
310 | if (opt & CPIO_OPT_PASSTHROUGH) { | 311 | if (opt & CPIO_OPT_PASSTHROUGH) { |
311 | pid_t pid; | 312 | pid_t pid; |
312 | struct fd_pair pp; | 313 | struct fd_pair pp; |
313 | 314 | ||
314 | if (argv[optind] == NULL) | 315 | if (argv[0] == NULL) |
315 | bb_show_usage(); | 316 | bb_show_usage(); |
316 | if (opt & CPIO_OPT_CREATE_LEADING_DIR) | 317 | if (opt & CPIO_OPT_CREATE_LEADING_DIR) |
317 | mkdir(argv[optind], 0777); | 318 | mkdir(argv[0], 0777); |
318 | /* Crude existence check: | 319 | /* Crude existence check: |
319 | * close(xopen(argv[optind], O_RDONLY | O_DIRECTORY)); | 320 | * close(xopen(argv[0], O_RDONLY | O_DIRECTORY)); |
320 | * We can also xopen, fstat, IS_DIR, later fchdir. | 321 | * We can also xopen, fstat, IS_DIR, later fchdir. |
321 | * This would check for existence earlier and cleaner. | 322 | * This would check for existence earlier and cleaner. |
322 | * As it stands now, if we fail xchdir later, | 323 | * As it stands now, if we fail xchdir later, |
@@ -335,14 +336,14 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
335 | #else | 336 | #else |
336 | xpiped_pair(pp); | 337 | xpiped_pair(pp); |
337 | #endif | 338 | #endif |
338 | pid = fork_or_rexec(argv); | 339 | pid = fork_or_rexec(argv - optind); |
339 | if (pid == 0) { /* child */ | 340 | if (pid == 0) { /* child */ |
340 | close(pp.rd); | 341 | close(pp.rd); |
341 | xmove_fd(pp.wr, STDOUT_FILENO); | 342 | xmove_fd(pp.wr, STDOUT_FILENO); |
342 | goto dump; | 343 | goto dump; |
343 | } | 344 | } |
344 | /* parent */ | 345 | /* parent */ |
345 | xchdir(argv[optind++]); | 346 | xchdir(*argv++); |
346 | close(pp.wr); | 347 | close(pp.wr); |
347 | xmove_fd(pp.rd, STDIN_FILENO); | 348 | xmove_fd(pp.rd, STDIN_FILENO); |
348 | opt &= ~CPIO_OPT_PASSTHROUGH; | 349 | opt &= ~CPIO_OPT_PASSTHROUGH; |
@@ -361,7 +362,6 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
361 | } | 362 | } |
362 | skip: | 363 | skip: |
363 | #endif | 364 | #endif |
364 | argv += optind; | ||
365 | 365 | ||
366 | archive_handle = init_handle(); | 366 | archive_handle = init_handle(); |
367 | archive_handle->src_fd = STDIN_FILENO; | 367 | archive_handle->src_fd = STDIN_FILENO; |
@@ -407,7 +407,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv) | |||
407 | 407 | ||
408 | while (*argv) { | 408 | while (*argv) { |
409 | archive_handle->filter = filter_accept_list; | 409 | archive_handle->filter = filter_accept_list; |
410 | llist_add_to(&(archive_handle->accept), *argv); | 410 | llist_add_to(&archive_handle->accept, *argv); |
411 | argv++; | 411 | argv++; |
412 | } | 412 | } |
413 | 413 | ||