Page MenuHomeFreeBSD

save-entropy: Fix the guard to avoid non-digits
Needs ReviewPublic

Authored by jlduran on Nov 16 2024, 10:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 6 2024, 11:42 PM
Unknown Object (File)
Nov 23 2024, 11:43 AM
Unknown Object (File)
Nov 21 2024, 11:01 PM
Unknown Object (File)
Nov 21 2024, 7:42 PM
Unknown Object (File)
Nov 19 2024, 7:09 PM
Unknown Object (File)
Nov 18 2024, 6:12 PM
Unknown Object (File)
Nov 18 2024, 5:27 PM
Unknown Object (File)
Nov 18 2024, 4:51 PM
Subscribers

Details

Reviewers
emaste
des
0mp
Summary

Fix a guard that prevents a comparison with a non-digit to fail the
script.

Test Plan
touch ${entropy_dir}/saved-entropy.    # SKIP
touch ${entropy_dir}/saved-entropyx    # SKIP
touch ${entropy_dir}/saved-entropy.\*  # THE CURRENT CHECK (SKIP)
touch ${entropy_dir}/saved-entropy.0   # PASS
touch ${entropy_dir}/saved-entropy.01  # PASS
touch ${entropy_dir}/saved-entropy.1a  # SKIP
touch ${entropy_dir}/saved-entropy.9   # PASS
touch ${entropy_dir}/saved-entropy.a   # SKIP

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 60635
Build 57519: arc lint + arc unit

Event Timeline

While studying for D47502, I stumbled upon the save-entropy.sh script. This part of the script seems wrong to me.
What I can infer is that this tries to guard against failing a comparison with a non-digit on the next line, by checking that whatever comes after saved-entropy. is a digit. Currently it is only checking for saved-entropy.\* (a literal *).
I don't know whom to ask for review. This change is low-priority, as it only verifies correctness, only root can write to the $entropy_dir.
Thank you!

libexec/save-entropy/save-entropy.sh
71
72

drop this

libexec/save-entropy/save-entropy.sh
72

Your suggestion would fail if there is a file named saved-entropy.1a, for example ([: 1a: bad number).

libexec/save-entropy/save-entropy.sh
72

You'll have to weigh how likely that is to happen up against the cost of the added complexity required to deal with the situation.