View Single Post
Old 04-17-2012, 03:00 PM   #337
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,637
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi,

The bug is in Mobi_Unpack in the file mobi_split.py. The test for srcs > 0 ignores the fact that the srcs value is unsigned and therefore tries to unpack it even when it should not.

Here is the fix:

Code:
--- mobi_split.py~	2012-03-01 18:16:17.000000000 -0500
+++ mobi_split.py	2012-04-17 14:53:18.000000000 -0400
@@ -241,7 +241,7 @@
         # check if there are SRCS records and delete them
         srcs = getint(datain_rec0,srcs_index)
         num_srcs = getint(datain_rec0,srcs_count)
-        if srcs > 0:
+        if srcs != 0xffffffff and num_srcs > 0:
             self.result_file7 = deletesectionrange(self.result_file7,srcs,srcs+num_srcs-1)
             datain_rec0 = writeint(datain_rec0,srcs_index,0xffffffff)
             datain_rec0 = writeint(datain_rec0,srcs_count,0)
Using any good text editor, edit the file lib/mobi_split.py and go to line 244 and replace

if srcs > 0:

with

if srcs != 0xffffffff and num_srcs > 0:

being careful to make sure you do not mess up the indentation level (whitespace at the beginning of that line).

If it would help, I can post a pre-release version of Mobi_Unpack_v049 - with that fix. We are waiting for Calibre to support the .azw3 file extension for standalone mobi8 mobi files before releasing.

Thanks for the bug report.

KevinH
KevinH is offline   Reply With Quote