[Chinese-commits] [zhcon] 06/10: Fix zhcon crash with built-in input methods on 64-bit platform
Anthony Fok
foka at debian.org
Thu Nov 19 13:24:59 UTC 2015
This is an automated email from the git hooks/post-receive script.
foka pushed a commit to branch master
in repository zhcon.
commit 729fca505bda890c511a7fc8daf9291808813f1f
Author: Anthony Fok <foka at debian.org>
Date: Thu Nov 19 06:09:23 2015 -0700
Fix zhcon crash with built-in input methods on 64-bit platform
Closes: #805544
---
debian/patches/0011-winime-64bit-fix.patch | 172 +++++++++++++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 173 insertions(+)
diff --git a/debian/patches/0011-winime-64bit-fix.patch b/debian/patches/0011-winime-64bit-fix.patch
new file mode 100644
index 0000000..e52a23b
--- /dev/null
+++ b/debian/patches/0011-winime-64bit-fix.patch
@@ -0,0 +1,172 @@
+Description: Fix zhcon crash with built-in input methods on 64-bit platform
+ Md82 fixed a zhcon crash when the user tries to type after enabling
+ the built-in Chinese input method. The fix was posted to the LinuxDev
+ board on SMTH BBS on 2008-10-11, accessible through this URL:
+ .
+ http://www.newsmth.net/nForum/#!article/LinuxDev/29280
+ .
+ ==============================================================================
+ 发信人: Md82 (我是KCN的一条狗啊), 信区: LinuxDev
+ 标 题: 一上午时间终于把zhcon的输入法在x86-64调通
+ 发信站: 水木社区 (Sat Oct 11 09:36:29 2008), 站内
+ .
+ zhcon0.2.6的输入法不能在 x86-64上运行,一输入字符就报告段错误
+ fedora9和fedora10打包的两个binary rpm也一样的问题
+ .
+ 阅读代码后发现原作者假设所有机器都是32位指针,所以直接把码表文件(每单元4bytes)
+ 映射到char**数组。在x86-64中,一个char*占了8字节,结果变成由两个码表的偏移量数
+ 值错位32后或出来,明显会超界。
+ .
+ 解决办法是把几个数组从char**改成int *,以及修改了相关的偏移量计算代码。现在终
+ 于可以在console灌水了。
+ .
+ 具体修改的文件是src/winime.cpp和src/winime.h。
+ --
+ .
+ 自由对于笨人是极端痛苦的事情,不亚于把他们投入真空。
+ 对于聪明人则不然。
+ .
+ .
+ ※ 修改:·Md82 于 Oct 11 09:38:01 2008 修改本文·[FROM: 115.130.13.*]
+ ※ 来源:·水木社区 http://newsmth.net·[FROM: 115.130.13.*]
+ .
+ .
+ 附件(8.7KB) winime.cpp (http://att.newsmth.net/nForum/att/LinuxDev/29280/839)
+ 附件(2.8KB) winime.h (http://att.newsmth.net/nForum/att/LinuxDev/29280/9818)
+ ==============================================================================
+
+Author: Md82 at bbs.newsmth.net
+Origin: other
+Bug-Debian: https://bugs.debian.org/501912, https://bugs.debian.org/805544
+Forwarded: no
+Reviewed-by: Yu Guanghui <ygh at debian.org>, Anthony Fok <foka at debian.org>
+Last-Update: 2015-11-19
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/src/winime.cpp
++++ b/src/winime.cpp
+@@ -56,10 +56,10 @@
+
+ memcpy(&mHead, mpBuf, sizeof(mHead));
+ int len = strlen(mHead.mCodeSet);
+- mpIndex1 = (char **) (mpBuf + sizeof(mHead));
+- mpIndex2 = (char **) (mpBuf + sizeof(mHead) + len * sizeof(char *));
+- mpText = mpBuf + sizeof(mHead) + len * sizeof(char *) +
+- len * len * sizeof(char *);
++ mpIndex1 = (int *) (mpBuf + sizeof(mHead));
++ mpIndex2 = (int *) (mpBuf + sizeof(mHead) + len * sizeof(int));
++ mpText = mpBuf + sizeof(mHead) + len * sizeof(int) +
++ len * len * sizeof(int);
+ }
+
+ WinIme::~WinIme() {
+@@ -74,7 +74,7 @@
+ return false;
+ }
+ //add a word to candilist then push rp forward
+-void WinIme::AddCandilist(char *&rp,unsigned long& buflen) {
++void WinIme::AddCandilist(char *&rp,unsigned int& buflen) {
+ assert(mpList->mCount < 10);
+ assert(!IsHzCode1(*rp)); //*rp is last matched latter
+
+@@ -163,7 +163,7 @@
+ count--;
+ break;
+ }
+- AddCandilist(t,(unsigned long&)buflen);
++ AddCandilist(t,(unsigned int&)buflen);
+ } //search next word
+ else {
+ if (len == 1) //special for first char
+@@ -231,6 +231,9 @@
+ char *p = NULL;
+ bool found = true;
+ mInput[mNum] = c;
++
++
++
+ if (mNum == 0) {
+ //1st level index
+ //maybe prevent wildchar in 1st index is a good ideal
+@@ -246,7 +249,9 @@
+ // p = *t;
+ }
+ else
+- p = mpIndex1[Index(c)];
++ {
++ p = (char *)mpIndex1[Index(c)];
++ }
+
+ if (p == (char *) 0xffffffff)
+ found = false;
+@@ -257,20 +262,24 @@
+ if (c == mHead.mWildChar) {
+ char **t;
+ t =
+- find_if(mpIndex2 + Index(mInput[0]) * l,
+- mpIndex2 + (Index(mInput[0]) + 1) * l,
++ find_if((char **)(mpIndex2 + Index(mInput[0]) * l),
++ (char **)(mpIndex2 + (Index(mInput[0]) + 1) * l),
+ bind2nd(not_equal_to < char *>(),
+ (char *) 0xffffffff));
+- if (t == mpIndex2 + (Index(mInput[0]) + 1) * l)
++ if (t == ((char **)mpIndex2) + (Index(mInput[0]) + 1) * l)
++ {
+ p = (char *) 0xffffffff;
++ }
+ else
+ p = *t;
+ } else
+- p = mpIndex2[Index(mInput[0]) * l + Index(c)];
++ {
++ int dd = Index(mInput[0]) * l + Index(c);
++ p = (char *)(mpIndex2[Index(mInput[0]) * l + Index(c)]);
++ }
+
+ if (p == (char *) 0xffffffff)
+ found = false;
+-
+ p = (unsigned long) p + mpText;
+ } else if (mNum < mHead.mMaxCodes) {
+ p = mpOffset[mNum - 1];
+--- a/src/winime.h
++++ b/src/winime.h
+@@ -45,7 +45,7 @@
+ string GetName();
+ bool InCodeSet(char c) const;
+ int Search(string& s, int start);
+- void SetCandilist(Candilist* p,unsigned long len = 1000) {
++ void SetCandilist(Candilist* p,unsigned len = 1000) {
+ mpList = p;
+ mCandilistBufLen = len;
+ }
+@@ -69,7 +69,7 @@
+ return c >= 0xA1 && c <= 0xFE;
+ }
+
+- void AddCandilist(char*& p,unsigned long& buflen);
++ void AddCandilist(char*& p,unsigned& buflen);
+ void SkipNext(char*& rp);
+ int MatchWord(char* p, int len, int offset);
+ bool IsGB2312(char* p);
+@@ -80,15 +80,15 @@
+ char mInput[12 + 1];
+ bool mGBKOut;
+ Candilist* mpList;
+- char* mpOffset[12];
++ char * mpOffset[12];
+ int mFd;
+ char* mpBuf;
+- char** mpIndex1;
+- char** mpIndex2;
++ int *mpIndex1;
++ int *mpIndex2;
+ char* mpText;
+ char* mpCur; //current search position
+- unsigned long mBufSize;
+- unsigned long mCandilistBufLen;
++ unsigned int mBufSize;
++ unsigned int mCandilistBufLen;
+ WinImeHead mHead;
+ };
+ #endif
diff --git a/debian/patches/series b/debian/patches/series
index 659c491..a56a6ba 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -8,3 +8,4 @@
# 0008-default-to-utf8.patch
0009-remove-rpath-from-configure.patch
0010-install-fonts-and-ime-tables-to-usr-share.patch
+0011-winime-64bit-fix.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/chinese/zhcon.git
More information about the Chinese-commits
mailing list