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

nc requires open stdin to not terminate early #538

Open
haarp opened this issue Jan 15, 2025 · 1 comment
Open

nc requires open stdin to not terminate early #538

haarp opened this issue Jan 15, 2025 · 1 comment

Comments

@haarp
Copy link

haarp commented Jan 15, 2025

Hey,

I found a bug in Toybox 0.8.11 on a CalyxOS device. nc appears to require something on its stdin, or it will terminate after a random amount of time/data. This can be problematic inside scripts or SSH sessions where stdin is not available or redirected from /dev/null.

Reproducer:

# provider
dd if=/dev/random bs=1M count=10 | /system/bin/nc -s 127.0.0.1 -l -p 8000 -w 10 &
sleep 1
# consumer
/system/bin/nc 127.0.0.1 8000 | wc -c

reads all of the 10M bytes (if run in an interactive shell!)

# provider
dd if=/dev/random bs=4M count=10 | /system/bin/nc -s 127.0.0.1 -l -p 8000 -w 10 &
sleep 1
# consumer
</dev/null /system/bin/nc 127.0.0.1 8000 | wc -c

nc terminates after reading 0 to a few thousand bytes

Thanks!

@haarp
Copy link
Author

haarp commented Jan 15, 2025

A hacky workaround when provider and consumer are in the same shell:

while [ -e /proc/$! ]; do sleep 1; done | /system/bin/nc 127.0.0.1 8000

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

No branches or pull requests

1 participant