Skip to content

Conversation

@horner
Copy link
Contributor

@horner horner commented Feb 17, 2024

fixed a rare condition where the comparison may not be made within the second and then this will loop forever (or at least until a rollover of SECONDS) ;-)

sleep was replaced in #1707

But if safe_sleep.sh is running when a vm is suspended it will not do the comparison within the second and therefore loops forever when the vm is resumed.

@horner horner requested a review from a team as a code owner February 17, 2024 16:38
@horner
Copy link
Contributor Author

horner commented Feb 17, 2024

Screenshot 2024-02-17 at 11 19 18 AM

@ericsciple ericsciple enabled auto-merge (squash) August 20, 2025 18:40
@ericsciple ericsciple disabled auto-merge August 20, 2025 18:47
@ericsciple ericsciple enabled auto-merge (squash) August 20, 2025 18:47
fixed a rare condition where the comparison may not be made within the second and then this will loop forever (or at least until a rollover of SECONDS)  ;-)
@ericsciple ericsciple merged commit 20d82ad into actions:main Aug 20, 2025
9 checks passed
@andrewrk
Copy link

fixed a rare condition

I assume you mean "rare" as in, "not finished cooking" because it happens all the damn time

@paralin
Copy link

paralin commented Nov 29, 2025

Is looping infinitely really an effective sleep?

@AXDOOMER
Copy link

Why are they not using the sleep command?

@inthesquarehole
Copy link

Why does a complete amateur work on code used by so many? Not that I use it, but this is just retarded.

@NicolasDorier
Copy link

NicolasDorier commented Dec 8, 2025

I would suggest to just use sleep if available instead of doing something as extremely inefficient as that just so the 0.0001% of systems who doesn't have sleep can work.

Or better, just drop a sleep script in the PATH of the systems not supporting sleep by default... This might literally saves us from climate change.

@bybatkhuu
Copy link

bybatkhuu commented Dec 10, 2025

Came from "primeagen" content, holys**t it's real???
WOW!

@symmetricalbyte
Copy link

“A remarkable demonstration of how far one can stretch the boundaries of conventional engineering wisdom.”

@jcastrence
Copy link

Ironically named "safe_sleep.sh" 😭

Technically, I guess it is safer to simply not run your code at all.

@Rudxain
Copy link

Rudxain commented Dec 10, 2025

Sadly, this is now vulnerable to code-injection (see SC issue), because != is a string comparison and -lt is a numeric comparison

Bash is taking inspiration from PHP's insanity

@latekvo
Copy link

latekvo commented Dec 10, 2025

@Rudxain nice catch, I tested it on my end, and it actually allows for RCE

But as far as I see, safe_sleep.sh is never used with user input, so I don't think it's that serious. Still should be fixed in case it's exposed to the user in the future though.

@ngxson
Copy link

ngxson commented Dec 10, 2025

read -t $1

No external program needed

@andrzejsokolowski
Copy link

Doesn't this still take up an entire core of a CPU? Is this malicious code designed to waste as much processor compute time? Isn't this running this comparison billions of times a second? As other people pointed out in this thread, why not use sleep or other alternatives?

@pasabanov
Copy link

Isn't this running this comparison billions of times a second?

Not billions - bash is not that fast, but probably millions.
This still takes up an entire thread of the CPU.

why not use sleep or other alternatives?

This is a reasonable question. They previously had code that checked for programs like sleep or ping to use them if available, but they replaced it with this abomination.

@whoreson
Copy link

put me in the screenshot

@lachesis
Copy link

Under what circumstance is sleep actually not available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.