diff toys/other/chroot.c @ 955:144d5ba7d410

Replace users of xexec(toys.optargs) with xexec_optargs(0) to avoid free/reuse bug during argument parsing.
author Rob Landley <rob@landley.net>
date Thu, 18 Jul 2013 18:20:03 -0500
parents 786841fdb1e0
children cbb1aca81eca
line wrap: on
line diff
--- a/toys/other/chroot.c	Wed Jul 17 17:27:14 2013 -0500
+++ b/toys/other/chroot.c	Thu Jul 18 18:20:03 2013 -0500
@@ -18,6 +18,8 @@
 void chroot_main(void)
 {
   char *binsh[] = {"/bin/sh", "-i", 0};
+
   if (chdir(*toys.optargs) || chroot(".")) perror_exit("%s", *toys.optargs);
-  xexec(toys.optargs[1] ? toys.optargs+1 : binsh);
+  if (toys.optargs[1]) xexec_optargs(1);
+  else xexec(binsh);
 }