summaryrefslogtreecommitdiff
path: root/hwpfilter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-02-24 19:25:01 +0000
committerAndras Timar <andras.timar@collabora.com>2018-03-06 16:34:48 +0100
commit0609e6319fecd40667b396a167ea8cef9c6de970 (patch)
tree022f7cfbd1686d5b72819f4e779bcf52a5ee3baa /hwpfilter
parent9224ddf368b2c0397afc3f3d48ac318c3a5f4cb4 (diff)
forcepoint #7 check ksc5601_2uni_page21 bounds
Change-Id: I578e7a63bb50f2088d35174d88f075c00469bad3 Reviewed-on: https://gerrit.libreoffice.org/50287 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit bdf30af5c2323e6f84e4bea8c7fbbcafa1dc91b3)
Diffstat (limited to 'hwpfilter')
-rw-r--r--hwpfilter/source/hcode.cxx28
1 files changed, 11 insertions, 17 deletions
diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index 9aaa9e98f04a..606a3dcfcf5e 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -1139,14 +1139,11 @@ int kssm_hangul_to_ucs2(hchar ch, hchar *dest)
hchar ksc5601_sym_to_ucs2 (hchar input)
{
unsigned char ch = sal::static_int_cast<unsigned char>(input >> 8);
- unsigned char ch2;
- int idx;
-
- ch2 = sal::static_int_cast<unsigned char>(input & 0xff);
- idx = (ch - 0xA1) * 94 + (ch2 - 0xA1);
- if (idx <= 1114 && idx >= 0){
- hchar value = ksc5601_2uni_page21[idx];
- return value ? value : 0x25a1;
+ unsigned char ch2 = sal::static_int_cast<unsigned char>(input & 0xff);
+ int idx = (ch - 0xA1) * 94 + (ch2 - 0xA1);
+ if (idx >= 0 && idx < static_cast<int>(SAL_N_ELEMENTS(ksc5601_2uni_page21))) {
+ hchar value = ksc5601_2uni_page21[idx];
+ return value ? value : 0x25a1;
}
return 0x25a1;
}
@@ -1154,15 +1151,12 @@ hchar ksc5601_sym_to_ucs2 (hchar input)
hchar ksc5601_han_to_ucs2 (hchar input)
{
unsigned char ch = sal::static_int_cast<unsigned char>(input >> 8);
- unsigned char ch2;
- int idx;
-
- ch2 = sal::static_int_cast<unsigned char>(input & 0xff);
- idx = (ch - 0xA1) * 94 + (ch2 - 0xA1);
- if (idx >= 3854){
- // Hanja : row 42 - row 93 : 3854 = 94 * (42-1)
- hchar value = ksc5601_2uni_page21[idx - 3854];
- return value ? value : '?';
+ unsigned char ch2 = sal::static_int_cast<unsigned char>(input & 0xff);
+ int idx = (ch - 0xA1) * 94 + (ch2 - 0xA1);
+ if (idx >= 3854 && idx < static_cast<int>(3854 + SAL_N_ELEMENTS(ksc5601_2uni_page21))) {
+ // Hanja : row 42 - row 93 : 3854 = 94 * (42-1)
+ hchar value = ksc5601_2uni_page21[idx - 3854];
+ return value ? value : '?';
}
return '?';
}