Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Potential memory issue in PIPE #45

Open
cpiber opened this issue Feb 10, 2022 · 0 comments
Open

Potential memory issue in PIPE #45

cpiber opened this issue Feb 10, 2022 · 0 comments

Comments

@cpiber
Copy link

cpiber commented Feb 10, 2022

Please correct me if I'm wrong, but I think you have a memory issue. In

nobuild/nobuild.h

Lines 752 to 762 in 47e280e

if (fdin) {
if (dup2(*fdin, STDIN_FILENO) < 0) {
PANIC("Could not setup stdin for child process: %s", strerror(errno));
}
}
if (fdout) {
if (dup2(*fdout, STDOUT_FILENO) < 0) {
PANIC("Could not setup stdout for child process: %s", strerror(errno));
}
}
you de-reference the input fds, but in
Pipe pip = {0};
you create that on the stack, once for all of them. You overwrite them in each iteration. But afaik you are not guaranteed that the child runs and de-references those pointers before you get to the next command in the loop.

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

No branches or pull requests

1 participant