1 |
ssuominen 10/05/03 23:45:56 |
2 |
|
3 |
Added: stardict-3.0.1-sparc_sigbus.patch |
4 |
Log: |
5 |
Fix sparc/sigbus wrt #265792 by Tiago Cunha. |
6 |
(Portage version: 2.2_rc67/cvs/Linux x86_64) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 app-text/stardict/files/stardict-3.0.1-sparc_sigbus.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-text/stardict/files/stardict-3.0.1-sparc_sigbus.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-text/stardict/files/stardict-3.0.1-sparc_sigbus.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: stardict-3.0.1-sparc_sigbus.patch |
15 |
=================================================================== |
16 |
http://bugs.gentoo.org/show_bug.cgi?id=265792 |
17 |
|
18 |
by Tiago Cunha |
19 |
|
20 |
diff -ru stardict-3.0.1.orig/src/lib/getuint32.h stardict-3.0.1/src/lib/getuint32.h |
21 |
--- stardict-3.0.1.orig/src/lib/getuint32.h 2010-03-11 21:25:04.349799973 +0000 |
22 |
+++ stardict-3.0.1/src/lib/getuint32.h 2010-03-11 21:46:59.029797974 +0000 |
23 |
@@ -1,7 +1,9 @@ |
24 |
#ifndef _SD_GET_UINT32_H_ |
25 |
#define _SD_GET_UINT32_H_ |
26 |
|
27 |
-#ifdef ARM |
28 |
+#include <string.h> |
29 |
+ |
30 |
+#if defined(ARM) || defined(__sparc__) |
31 |
static inline guint32 get_uint32(const gchar *addr) |
32 |
{ |
33 |
guint32 result; |
34 |
diff -ru stardict-3.0.1.orig/src/lib/stddict.cpp stardict-3.0.1/src/lib/stddict.cpp |
35 |
--- stardict-3.0.1.orig/src/lib/stddict.cpp 2010-03-11 21:25:04.339799373 +0000 |
36 |
+++ stardict-3.0.1/src/lib/stddict.cpp 2010-03-11 21:53:30.415449981 +0000 |
37 |
@@ -260,8 +260,12 @@ |
38 |
delete mf; |
39 |
return NULL; |
40 |
} |
41 |
- |
42 |
- gchar *p = mf->begin(); |
43 |
+ guint32 word_off_size = (get_uint32(mf->begin()) + 1) * sizeof(guint32); |
44 |
+ if (word_off_size >= cachestat.st_size || |
45 |
+ *(mf->begin() + cachestat.st_size - 1) != '\0') |
46 |
+ return NULL; |
47 |
+ |
48 |
+ gchar *p = mf->begin() + word_off_size; |
49 |
gboolean has_prefix; |
50 |
if (cachefiletype == CacheFileType_oft) |
51 |
has_prefix = g_str_has_prefix(p, OFFSETFILE_MAGIC_DATA); |
52 |
@@ -314,7 +318,7 @@ |
53 |
} |
54 |
g_free(tmpstr); |
55 |
} |
56 |
- if (cachestat.st_size!=glong(filedatasize + strlen(mf->begin()) +1)) { |
57 |
+ if (cachestat.st_size != static_cast<gulong>(filedatasize + sizeof(guint32) + strlen(mf->begin() + word_off_size) +1)) { |
58 |
delete mf; |
59 |
return NULL; |
60 |
} |
61 |
@@ -375,7 +379,7 @@ |
62 |
mf = get_cache_loadfile(oftfilename.c_str(), url, saveurl, cltfunc, filedatasize, 2); |
63 |
if (!mf) |
64 |
continue; |
65 |
- wordoffset = (guint32 *)(mf->begin()+strlen(mf->begin())+1); |
66 |
+ wordoffset = reinterpret_cast<guint32 *>(mf->begin()) + 1; |
67 |
return true; |
68 |
} |
69 |
return false; |
70 |
@@ -425,7 +429,12 @@ |
71 |
if (!mf.open(filename, oftstat.st_size)) { |
72 |
return fopen(filename, "wb"); |
73 |
} |
74 |
- gchar *p = mf.begin(); |
75 |
+ guint32 word_off_size = (get_uint32(mf.begin()) + 1) * sizeof(guint32); |
76 |
+ if (word_off_size >= oftstat.st_size || |
77 |
+ *(mf.begin() + oftstat.st_size - 1) != '\0') |
78 |
+ return fopen(filename, "wb"); |
79 |
+ |
80 |
+ gchar *p = mf.begin() + word_off_size; |
81 |
bool has_prefix; |
82 |
if (cachefiletype == CacheFileType_oft) |
83 |
has_prefix = g_str_has_prefix(p, OFFSETFILE_MAGIC_DATA); |
84 |
@@ -506,6 +515,9 @@ |
85 |
FILE *out= get_cache_savefile(oftfilename.c_str(), url, 2, cfilename, cltfunc); |
86 |
if (!out) |
87 |
continue; |
88 |
+ guint32 nentries = npages; |
89 |
+ fwrite(&nentries, sizeof(nentries), 1, out); |
90 |
+ fwrite(wordoffset, sizeof(guint32), npages, out); |
91 |
if (cachefiletype == CacheFileType_oft) |
92 |
fwrite(OFFSETFILE_MAGIC_DATA, 1, sizeof(OFFSETFILE_MAGIC_DATA)-1, out); |
93 |
else |
94 |
@@ -520,7 +532,6 @@ |
95 |
#endif |
96 |
} |
97 |
fwrite("\n", 1, 2, out); |
98 |
- fwrite(wordoffset, sizeof(guint32), npages, out); |
99 |
fclose(out); |
100 |
g_print("Save cache file: %s\n", cfilename.c_str()); |
101 |
return true; |