Previously, if `cpio_vec_insert()` needed to replace a file and the file
already exists as the first entry, then a duplicate entry would get
created.
This fixes the bug I reported at:
https://forum.xda-developers.com/showpost.php?p=75449768&postcount=22647
Signed-off-by: Andrew Gunnerson <andrewgunnerson@gmail.com>
Some functions, like `patch_init_rc()`, treat buffers read into memory
as a string instead of a byte buffer. Since the buffers weren't
NULL-terminated, this resulted in out-of-bounds reads and caused crashes
in certain conditions.
THis commit updates fd_full_read() to always NULL-terminate the buffers
so that they can be treated as strings when working with text files.
Signed-off-by: Andrew Gunnerson <andrewgunnerson@gmail.com>