mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 05:29:25 +00:00
Fix POSIX compliance of increase_default_stack_size.sh
It turns out `\xXX` is not part of POSIX. The Octal `\ddd` is however, and is used here.
This commit is contained in:
@@ -26,6 +26,9 @@ hex() {
|
|||||||
read_bytes() {
|
read_bytes() {
|
||||||
dd bs=1 skip="$1" count="$2" if="$ELF" 2> /dev/null | hex
|
dd bs=1 skip="$1" count="$2" if="$ELF" 2> /dev/null | hex
|
||||||
}
|
}
|
||||||
|
hex_to_octal() {
|
||||||
|
printf "ibase=16; obase=8; %s\n" "$1" | bc
|
||||||
|
}
|
||||||
write_bytes() {
|
write_bytes() {
|
||||||
POS=$1
|
POS=$1
|
||||||
BYTES=$2
|
BYTES=$2
|
||||||
@@ -34,15 +37,17 @@ write_bytes() {
|
|||||||
# Advance to the third byte, as in, after the first two bytes
|
# Advance to the third byte, as in, after the first two bytes
|
||||||
BYTES=$(printf "%s" "$BYTES" | tail -c+3)
|
BYTES=$(printf "%s" "$BYTES" | tail -c+3)
|
||||||
|
|
||||||
|
NEXT=$(hex_to_octal "$NEXT")
|
||||||
# shellcheck disable=SC2059
|
# shellcheck disable=SC2059
|
||||||
printf "\x$NEXT" | dd conv=notrunc bs=1 seek="$POS" of="$ELF" 2> /dev/null
|
printf \\"$NEXT" | dd conv=notrunc bs=1 seek="$POS" of="$ELF" 2> /dev/null
|
||||||
POS=$((POS + 1))
|
POS=$((POS + 1))
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Magic
|
# Magic
|
||||||
MAGIC=$(read_bytes 0 4)
|
MAGIC=$(read_bytes 0 4)
|
||||||
EXPECTED_MAGIC=$(printf "\x7ELF" | hex)
|
# shellcheck disable=SC2059
|
||||||
|
EXPECTED_MAGIC=$(printf \\"$(hex_to_octal 7F)"ELF | hex)
|
||||||
if [ ! "$MAGIC" = "$EXPECTED_MAGIC" ]; then
|
if [ ! "$MAGIC" = "$EXPECTED_MAGIC" ]; then
|
||||||
echo "Not ELF"
|
echo "Not ELF"
|
||||||
exit 2
|
exit 2
|
||||||
|
|||||||
Reference in New Issue
Block a user