summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
AgeCommit message (Collapse)Author
25 hoursanother correctionLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
25 hoursutil/nvmutil: fix regression on openbsdLeah Rowe
when i removed arc4random integration, i forgot to change this line back. oops! Signed-off-by: Leah Rowe <leah@libreboot.org>
25 hoursTODOLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
25 hoursTODOLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
26 hoursTODOLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursutil/nvmutil: mitigate buggy libc i/oLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursutil/nvmutil: implement zero-byte r/w timeoutLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursTODOLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursutil/nvmutil: add some useful commentsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursutil/nvmutil: split up rw_file_exactLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursfix indentationLeah Rowe
i was editting this in another editor Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: add jitter to fallback_rand entropyLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: improved entropy in fallback_randLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: remove /dev/random fallbackLeah Rowe
only use the old fallback, or /dev/urandom /dev/random blocks on some older unix machines, or in embedded environments that may never have enough entropy, causing the code to hang. urandom is most certainly expected to exist on pretty much anything since the mid 90s. i could probably re-add the arc4random setup for BSDs. i'll think about it. gotta do that portably too. Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: include time.h after types.hLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: mitigate fast calls to randLeah Rowe
if someone calls rhex fast enough, the timestamp may not change. this mitigates that by adding a counter value to the mix Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: fallback randomiserLeah Rowe
used when a random device isn't available, on old unix, or on certain chroot environments. Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: remove errno externLeah Rowe
may break modern systems. and all old systems that i care about will handle errno just fine. Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: fix commentLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: simplify flags on urandomLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: fix mistake in random checkLeah Rowe
forgot this. oops Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: portable errnoLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: fix non-portable variable declarationLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: disable urandom if not foundLeah Rowe
disable random mac address generation on really old operating systems. Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: use ECANCELED on checksum errLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: don't use errno for program stateLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: re-use do_rw() from prw()Leah Rowe
using a special leah-only technique Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: add missing sanitization testsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: properly use rc in rw_File_exactLeah Rowe
subtract and add iteratively Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: tidy up gbe_cat_buf()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: split up rw_file_exact()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: update some commentsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: re-add EINTR loop check on rwLeah Rowe
accidentally removed it during re-factor Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: rename set_err for code clarityLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: skip errno check in mainLeah Rowe
skip it if there is a valid checksum, to mitigate erroneous errno state upon exit from run_cmd(), because we can assume by this point that we are in fact ready to write at this point. the check at the end still exists, which will catch any error set by write, and any error set before that. this fixes a weird warning on cmd_dump. Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: don't reset errno in rw_file_exactLeah Rowe
reset it in callers instead. this means that the main function is more generalised. we know by the time we exit that there is no error. Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: reset errno in gbe_catLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: reset errno in gbe_cat_bufLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: fix bad loop in command sanitizerLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: use set_err where appropriateLeah Rowe
in the new file i/o functions, my own setting of errno should be done with set_err. this avoids clobbering what the real libc set. Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: properly set errno everywhereLeah Rowe
i set it to ecanceled before. now i set it more appropriately, for each type of error. where a real syscall was called, or my file i/o functions are used, err() is called with errno itself as input, to avoid clobbering real errno. Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: fix /dev/random fallbackLeah Rowe
i forgot to set urandom_fd Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysRevert "util/nvmutil: fix check in command sanitizer"Leah Rowe
This reverts commit b28076557b4c12965c15d6fad7c06e34c67f7921. nope. the check was already correct before.
3 daysutil/nvmutil: don't use bad pointer cast in prwLeah Rowe
in practise it's ok, but some compilers might complain. all this change costs is a bit of branching inside a loop, but compilers will sort that out. Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: fix check in command sanitizerLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: use EINVAL in command sanitizenLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: don't use xopen() for urandomLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: conservative use of errnoLeah Rowe
only use errno itself as the value Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: re-try /dev/[u]random on EAGAINLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
3 daysutil/nvmutil: Make rw_file_exact an ssize_tLeah Rowe
Use its return value. Don't exit from the function, but actually treat it like a real syscall. Signed-off-by: Leah Rowe <leah@libreboot.org>