Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master z-rejected grimoire by Thomas Orgis (7e6993efe1ef68e949e5d3e73dba828e55a64dc9)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Thomas Orgis <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master z-rejected grimoire by Thomas Orgis (7e6993efe1ef68e949e5d3e73dba828e55a64dc9)
  • Date: Mon, 30 May 2011 04:46:37 -0500

GIT changes to master z-rejected grimoire by Thomas Orgis
<sobukus AT sourcemage.org>:

z-http/flash/memcpy-to-memmove.sh | 40
++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+)

New commits:
commit 7e6993efe1ef68e949e5d3e73dba828e55a64dc9
Author: Thomas Orgis <sobukus AT sourcemage.org>
Commit: Thomas Orgis <sobukus AT sourcemage.org>

flash: Avoid nasty effects due to bad usage of memcpy, mostly apparent
with
glibc 2.13 . This is opt-in to make clear that it's the user deciding to
hack her binary, not the distro.

diff --git a/z-http/flash/memcpy-to-memmove.sh
b/z-http/flash/memcpy-to-memmove.sh
new file mode 100644
index 0000000..b1632e5
--- /dev/null
+++ b/z-http/flash/memcpy-to-memmove.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+# Quick and dirty, but inefficient shellscript that
+# turns all memcpy calls into memmove calls
+# From Ray Strode
+
+set -e
+
+INPUT="$1"
+
+MEMCPY=0x$(objdump -S -j .plt $INPUT | grep memcpy |awk '{ print $1 }')
+[ $MEMCPY = "0x" ] && echo "Can't find memcpy call in $INPUT PLT" 1>&2 &&
exit 1
+
+MEMMOVE=0x$(objdump -S -j .plt $INPUT | grep memmove |awk '{ print $1 }')
+[ $MEMMOVE = "0x" ] && echo "Can't find memmove call in $INPUT PLT" 1>&2 &&
exit 2
+
+DELTA=$(($MEMMOVE - $MEMCPY))
+MEMCPY="$(printf '%x' $MEMCPY)"
+
+TEMP_OUTPUT="$(mktemp)"
+trap "rm -f $TEMP_OUTPUT" ERR
+
+cp $INPUT $TEMP_OUTPUT
+objdump -S -j .text $INPUT | while read offset e8 byte1 byte2 byte3 byte4
call call_offset rest; do
+ test "$call_offset" = "$MEMCPY" || continue;
+
+ OFFSET=$(printf "0x%x" $((0x${offset%:} + 1)))
+ NUMBER="0x${byte4}${byte3}${byte2}${byte1}"
+ echo -n "Changing call at offset $OFFSET from [${byte1} ${byte2}
${byte3} ${byte4}]"
+ NUMBER=$(printf "0x%08x" $(($NUMBER + $DELTA)))
+
+ BYTE1=$(printf "%02x" $((($NUMBER >> 24) & 0xff)))
+ BYTE2=$(printf "%02x" $((($NUMBER >> 16) & 0xff)))
+ BYTE3=$(printf "%02x" $((($NUMBER >> 8) & 0xff)))
+ BYTE4=$(printf "%02x" $((($NUMBER >> 0) & 0xff)))
+
+ echo " to [${BYTE4} ${BYTE3} ${BYTE2} ${BYTE1}]"
+ echo -ne "\x$BYTE4\x$BYTE3\x$BYTE2\x$BYTE1" | dd of=$TEMP_OUTPUT bs=1
seek=$(($OFFSET)) count=4 conv=notrunc 2> /dev/null
+done
+
+mv $TEMP_OUTPUT $INPUT



  • [SM-Commit] GIT changes to master z-rejected grimoire by Thomas Orgis (7e6993efe1ef68e949e5d3e73dba828e55a64dc9), Thomas Orgis, 05/30/2011

Archive powered by MHonArc 2.6.24.

Top of Page