Skip to content

Commit

Permalink
feat: add file size check
Browse files Browse the repository at this point in the history
  • Loading branch information
shizhx committed Nov 22, 2022
1 parent 375556e commit f6ded24
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ if ! dd "if=${TMPDIR}/${TARGET_LIB}" bs=1 "skip=${FILE_OFFSET}" >> "${TMPDIR}/${
abort "Failed to patch ${TMPDIR}/${TARGET_LIB}, step3"
fi

# check file size
orig_size=$(stat -c "%s" "${TMPDIR}/${TARGET_LIB}")
patched_size=$(stat -c "%s" "${TMPDIR}/${PATCHED_LIB}")
if [ "$orig_size" != "$patched_size" ]; then
abort "Failed to patch ${TMPDIR}/${TARGET_LIB}: unexpected file size"
fi

# copy to target dir
mkdir -p "${MODPATH}/${TARGET_DIR}" || abort "Failed to create ${MODPATH}/${TARGET_DIR}"
cp -f "${TMPDIR}/${PATCHED_LIB}" "${MODPATH}/${TARGET_DIR}/${TARGET_LIB}" || abort "Failed to copy patched lib to target"
Expand Down

0 comments on commit f6ded24

Please sign in to comment.