mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
lib.sh: safer pad_one_byte function
instead of copying to a temp file and then concatenating with padding back to the main file, we concatenate and create the temp file, then move the temp file back to the main file. this is because cat can be quite error prone, more so than mv, so this will reduce the chance of corrupt files being left behind depending on the context (of course, the latter is often avoided due to xbmk's design, which emphasises use of temporary files first). this matches the same design used in the function unpad_one_byte, which creates the deconcatenated output in a temporary file first, moving it back. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+2
-3
@@ -98,9 +98,8 @@ findpath()
|
||||
pad_one_byte()
|
||||
{
|
||||
paddedfile="`mktemp`" || err "mktemp pad_one_byte"
|
||||
x_ cp "$1" "$paddedfile"
|
||||
x_ cat "$paddedfile" config/data/coreboot/0 > "$1" || err "!pad $1"; :
|
||||
x_ rm "$paddedfile"
|
||||
x_ cat "$1" config/data/coreboot/0 > "$paddedfile" || err "!pad $1"; :
|
||||
x_ mv "$paddedfile" "$1"
|
||||
}
|
||||
|
||||
unpad_one_byte()
|
||||
|
||||
Reference in New Issue
Block a user