Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

which: standard output: Bad file number #7

Closed
tux-mind opened this issue Nov 4, 2014 · 2 comments
Closed

which: standard output: Bad file number #7

tux-mind opened this issue Nov 4, 2014 · 2 comments
Assignees
Labels

Comments

@tux-mind
Copy link
Member

tux-mind commented Nov 4, 2014

when starting "which env" stdout pipe has some problems.

reported by @danktx

logcat: http://pastebin.com/raw.php?i=EYshJmff

@tux-mind tux-mind added the bug label Nov 4, 2014
@tux-mind tux-mind self-assigned this Nov 4, 2014
@tux-mind
Copy link
Member Author

tux-mind commented Nov 4, 2014

in the same logcat the same command is started successfully.

there is 2 reason that can change a program behaviour:

  • particular system state
  • race condition

due to #5 the system is running out of file descriptors,
probably this is the reason why the child has it's stdout closed.

have to find a way to check pipes functionality before exec the target program.

@tux-mind
Copy link
Member Author

tux-mind commented Nov 6, 2014

problem was that:
dSploitd redirects stdout and stdin to /dev/null for child that does not use it.

on certain cases the open("/dev/null", O_RDWR) returns a file descriptor less then 3.
then we were using dup2(dev_null_fd, 1) redirect child stdout.

after that we close the dev_null_fd, but it's value is less then 3, so we are closing a previously duplicated fd.

i have to study another case:
if pipe has the same number of the target fd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant