55817a1
Fix unalligned access to buffer.
55817a1
55817a1
On several architectures (arm, armel, sparc and ia64), unalligned access to
55817a1
integers is not allowed. Buffer in this function is not alligned at all and
55817a1
attempt to read integer from it causes crash of application on such
55817a1
architectures.
55817a1
55817a1
Reported upstream at:
55817a1
https://sourceforge.net/tracker/index.php?func=detail&aid=2149388&group_id=122858&atid=694730
55817a1
--- a/src/lib/lib.cpp
55817a1
+++ b/src/lib/lib.cpp
55817a1
@@ -496,9 +496,13 @@
55817a1
 		entries[i].keystr=p;
55817a1
 		len=strlen(p);
55817a1
 		p+=len+1;
55817a1
-		entries[i].off=g_ntohl(*reinterpret_cast<guint32 *>(p));
55817a1
+        /*
55817a1
+         * Can not use typecasting here, because *data does not have
55817a1
+         * to be alligned and unalligned access fails on some architectures.
55817a1
+         */
55817a1
+		entries[i].off=((unsigned char)p[0] << 24) | ((unsigned char)p[1] << 16) | ((unsigned char)p[2] << 8) | (unsigned char)p[3];
55817a1
 		p+=sizeof(guint32);
55817a1
-		entries[i].size=g_ntohl(*reinterpret_cast<guint32 *>(p));
55817a1
+		entries[i].size=((unsigned char)p[0] << 24) | ((unsigned char)p[1] << 16) | ((unsigned char)p[2] << 8) | (unsigned char)p[3];
55817a1
 		p+=sizeof(guint32);
55817a1
 	}
55817a1
 }