mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-16 19:50:19 +01:00
18bc18abd0
Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org>
27 lines
1.1 KiB
Diff
27 lines
1.1 KiB
Diff
From: Michal Čihař <nijel@debian.org>
|
|
Subject: Fix unalligned access to buffer.
|
|
|
|
On several architectures (arm, armel, sparc and ia64), unalligned access to
|
|
integers is not allowed. Buffer in this function is not alligned at all and
|
|
attempt to read integer from it causes crash of application on such
|
|
architectures.
|
|
|
|
Bug: https://sourceforge.net/tracker/index.php?func=detail&aid=2149388&group_id=122858&atid=694730
|
|
--- a/src/lib/lib.cpp
|
|
+++ b/src/lib/lib.cpp
|
|
@@ -496,9 +496,13 @@
|
|
entries[i].keystr=p;
|
|
len=strlen(p);
|
|
p+=len+1;
|
|
- entries[i].off=g_ntohl(*reinterpret_cast<guint32 *>(p));
|
|
+ /*
|
|
+ * Can not use typecasting here, because *data does not have
|
|
+ * to be alligned and unalligned access fails on some architectures.
|
|
+ */
|
|
+ entries[i].off=((unsigned char)p[0] << 24) | ((unsigned char)p[1] << 16) | ((unsigned char)p[2] << 8) | (unsigned char)p[3];
|
|
p+=sizeof(guint32);
|
|
- entries[i].size=g_ntohl(*reinterpret_cast<guint32 *>(p));
|
|
+ entries[i].size=((unsigned char)p[0] << 24) | ((unsigned char)p[1] << 16) | ((unsigned char)p[2] << 8) | (unsigned char)p[3];
|
|
p+=sizeof(guint32);
|
|
}
|
|
}
|