Because I haven't been able to get diff and patch to work, and checking around this seems to be because it doesn't work with CRLF files. Here's what I get in terminal (Mac OS X 10.5.6). Tell me what I'm doing wrong.
paul:Mobipocket Manipulation pdurrant$ diff -ud MobiDeDRM002.py MObiDeDRM005.py > patch2to5.txt
paul:Mobipocket Manipulation pdurrant$ patch -i patch2to5.txt -out MobiDeDRM005new.py MobiDeDRM002.py
patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.
paul:Mobipocket Manipulation pdurrant$ cat patch2to5.txt
--- MobiDeDRM002.py 2008-03-12 20:01:44.000000000 +0000
+++ MObiDeDRM005.py 2008-12-16 21:23:03.000000000 +0000
@@ -4,6 +4,9 @@
# Changelog
# 0.01 - Initial version
# 0.02 - Huffdic compressed books were not properly decrypted
+# 0.03 - Wasn't checking MOBI header length
+# 0.04 - Wasn't sanity checking size of data record
+# 0.05 - It seems that the extra data flags take two bytes not four
import sys,struct,binascii
@@ -60,6 +63,8 @@
def getSizeOfTrailingDataEntries(ptr, size, flags):
def getSizeOfTrailingDataEntry(ptr, size):
bitpos, result = 0, 0
+ if size <= 0:
+ return result
while True:
v = ord(ptr[size-1])
result |= (v & 0x7F) << bitpos
@@ -133,7 +138,11 @@
sect = self.loadSection(0)
records, = struct.unpack('>H', sect[0x8:0x8+2])
- extra_data_flags, = struct.unpack('>L', sect[0xF0:0xF4])
+ mobi_length, = struct.unpack('>L',sect[0x14:0x18])
+ extra_data_flags = 0
+ if mobi_length >= 0xE4:
+ extra_data_flags, = struct.unpack('>H', sect[0xF2:0xF4])
+
crypto_type, = struct.unpack('>H', sect[0xC:0xC+2])
if crypto_type != 2:
@@ -162,7 +171,7 @@
def getResult(self):
return self.data_file
-print "MobiDeDrm v0.02. Copyright (c) 2008 The Dark Reverser"
+print "MobiDeDrm v0.05. Copyright (c) 2008 The Dark Reverser"
if len(sys.argv)<4:
print "Removes protection from Mobipocket books"
print "Usage:"
paul:Mobipocket Manipulation pdurrant$
Quote:
Originally Posted by Gudy
Seconded. Have it produce a size-optimized, unified diff (Options -ud) and post the results. The unified diff file works both with GNU patch on any of the platforms where it is available/can be compiled, and is also the most easily human-readable of the various diff formats, IMO, so it also works well as instructions for applying the patch manually.
|