[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - hwpfilter/source

2018-02-26 Thread Caolán McNamara
 hwpfilter/source/hcode.cxx |   28 +++-
 1 file changed, 11 insertions(+), 17 deletions(-)

New commits:
commit 98a02abac221fdceb38d65b802be672948fc6ce1
Author: Caolán McNamara 
Date:   Sat Feb 24 19:25:01 2018 +

forcepoint #7 check ksc5601_2uni_page21 bounds

Change-Id: I578e7a63bb50f2088d35174d88f075c00469bad3
Reviewed-on: https://gerrit.libreoffice.org/50286
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index 31423c0a3db2..327dfc13dc07 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(input >> 8);
-unsigned char ch2;
-int idx;
-
-ch2 = sal::static_int_cast(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(input & 0xff);
+int idx = (ch - 0xA1) * 94 + (ch2 - 0xA1);
+if (idx >= 0 && idx < 
static_cast(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(input >> 8);
-unsigned char ch2;
-int idx;
-
-ch2 = sal::static_int_cast(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(input & 0xff);
+int idx = (ch - 0xA1) * 94 + (ch2 - 0xA1);
+if (idx >= 3854 && idx < static_cast(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 '?';
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - hwpfilter/source

2018-02-26 Thread Caolán McNamara
 hwpfilter/source/hinfo.cxx   |   11 ++-
 hwpfilter/source/hinfo.h |2 +-
 hwpfilter/source/hpara.cxx   |4 ++--
 hwpfilter/source/hwpfile.cxx |6 +++---
 hwpfilter/source/hwpfile.h   |5 ++---
 5 files changed, 14 insertions(+), 14 deletions(-)

New commits:
commit 7567beec1f7accf8b6d42ca68fd2c96a6d68ac48
Author: Caolán McNamara 
Date:   Sat Feb 24 20:43:12 2018 +

forcepoint #8 ensure ColumnDef lifetime

Change-Id: Idb0c7b1530dc57f4d7c14751f1b76caecc3b03a6
Reviewed-on: https://gerrit.libreoffice.org/50289
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/hwpfilter/source/hinfo.cxx b/hwpfilter/source/hinfo.cxx
index d6b30ee6b815..aab00beb36f2 100644
--- a/hwpfilter/source/hinfo.cxx
+++ b/hwpfilter/source/hinfo.cxx
@@ -202,6 +202,7 @@ ParaShape::ParaShape()
 , pspacing_next(0)
 , condense(0)
 , arrange_type(0)
+, xColdef(new ColumnDef)
 , shade(0)
 , outline(0)
 , outline_continue(0)
@@ -241,17 +242,17 @@ void ParaShape::Read(HWPFile & hwpf)
 return;
 tab.position = tmp16;
 }
-hwpf.Read1b(, 1);
-hwpf.Read1b(, 1);
+hwpf.Read1b(&(xColdef->ncols), 1);
+hwpf.Read1b(&(xColdef->separator), 1);
 if (!hwpf.Read2b(tmp16))
 return;
-coldef.spacing = tmp16;
+xColdef->spacing = tmp16;
 if (!hwpf.Read2b(tmp16))
 return;
-coldef.columnlen = tmp16;
+xColdef->columnlen = tmp16;
 if (!hwpf.Read2b(tmp16))
 return;
-coldef.columnlen0 = tmp16;
+xColdef->columnlen0 = tmp16;
 hwpf.Read1b(, 1);
 hwpf.Read1b(, 1);
 hwpf.Read1b(_continue, 1);
diff --git a/hwpfilter/source/hinfo.h b/hwpfilter/source/hinfo.h
index 049082e39e28..2cdaba65b2da 100644
--- a/hwpfilter/source/hinfo.h
+++ b/hwpfilter/source/hinfo.h
@@ -292,7 +292,7 @@ struct ParaShape
 unsigned char condense;
 unsigned char arrange_type;
 TabSettabs[MAXTABS];
-ColumnDef coldef;
+std::shared_ptr xColdef;
 unsigned char shade;
 unsigned char outline;
 unsigned char outline_continue;
diff --git a/hwpfilter/source/hpara.cxx b/hwpfilter/source/hpara.cxx
index 79fd93145ad8..bd37b282a47f 100644
--- a/hwpfilter/source/hpara.cxx
+++ b/hwpfilter/source/hpara.cxx
@@ -124,8 +124,8 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag)
 }
 
 if (nch && !reuse_shape){
- if( pshape->coldef.ncols > 1 ) {
- hwpf.SetColumnDef(&(pshape->coldef));
+ if( pshape->xColdef->ncols > 1 ) {
+ hwpf.SetColumnDef(pshape->xColdef);
  }
 }
 
diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index 128be0caa7af..b49393238157 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -413,7 +413,7 @@ void HWPFile::TagsRead()
 ColumnDef *HWPFile::GetColumnDef(int num)
 {
 if (static_cast(num) < columnlist.size())
-return columnlist[num]->coldef;
+return columnlist[num]->xColdef.get();
 else
 return nullptr;
 }
@@ -570,12 +570,12 @@ void HWPFile::AddColumnInfo()
 setMaxSettedPage();
 }
 
-void HWPFile::SetColumnDef(ColumnDef *coldef)
+void HWPFile::SetColumnDef(const std::shared_ptr& rColdef)
 {
 ColumnInfo *cinfo = columnlist.back().get();
 if( cinfo->bIsSet )
 return;
-cinfo->coldef = coldef;
+cinfo->xColdef = rColdef;
 cinfo->bIsSet = true;
 }
 
diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h
index b205e986963a..fa2a8e6df2ac 100644
--- a/hwpfilter/source/hwpfile.h
+++ b/hwpfilter/source/hwpfile.h
@@ -72,11 +72,10 @@ class   HStream;
 struct ColumnInfo{
 int start_page;
 bool bIsSet;
-ColumnDef *coldef;
+std::shared_ptr xColdef;
 explicit ColumnInfo(int num){
 start_page = num;
 bIsSet = false;
-coldef = nullptr;
 }
 };
 
@@ -214,7 +213,7 @@ class DLLEXPORT HWPFile
 void AddBox(FBox *);
 void AddPage(){ m_nCurrentPage++;}
 void AddColumnInfo();
-void SetColumnDef(ColumnDef *coldef);
+void SetColumnDef(std::shared_ptr const &);
 void AddParaShape(std::shared_ptr const &);
 void AddCharShape(std::shared_ptr const &);
 void AddFBoxStyle(FBoxStyle *);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - hwpfilter/source

2018-02-22 Thread Caolán McNamara
 hwpfilter/source/hwpfile.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit a82a0c0e688e029b76598445bcce14e6468cac3b
Author: Caolán McNamara 
Date:   Tue Feb 20 16:26:21 2018 +

forcepoint #1

Thanks to Antti Levomäki and Christian Jalio from Forcepoint.

Change-Id: Ic5e9a9d0f8f8d35cb6b39e68338ba029948a4ce0
Reviewed-on: https://gerrit.libreoffice.org/50083
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h
index 470fa2bdfd41..b205e986963a 100644
--- a/hwpfilter/source/hwpfile.h
+++ b/hwpfilter/source/hwpfile.h
@@ -230,7 +230,7 @@ class DLLEXPORT HWPFile
 HWPInfo& GetHWPInfo(void) { return _hwpInfo; }
 HWPFont& GetHWPFont(void) { return _hwpFont; }
 HWPStyle& GetHWPStyle(void) { return _hwpStyle; }
-HWPPara *GetFirstPara(void) { return plist.front().get(); }
+HWPPara *GetFirstPara(void) { return !plist.empty() ? 
plist.front().get() : nullptr; }
 
 EmPicture *GetEmPicture(Picture *pic);
 EmPicture *GetEmPictureByName(char * name);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - hwpfilter/source

2018-02-22 Thread Caolán McNamara
 hwpfilter/source/hcode.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 8381d6b95caf5dabf671861e1cafa24596584dfa
Author: Caolán McNamara 
Date:   Tue Feb 20 16:33:38 2018 +

forcepoint #2

Thanks to Antti Levomäki and Christian Jalio from Forcepoint.

Change-Id: Ie2b644a3c4c1c165334768eea73d451f07f97def
Reviewed-on: https://gerrit.libreoffice.org/50081
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index 1e0170401dca..31423c0a3db2 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -1217,6 +1217,8 @@ hchar_string hstr2ucsstr(hchar const* hstr)
 hchar_string kstr2hstr(unsigned char const* src)
 {
 hchar_string ret;
+if (!src)
+return ret;
 for (unsigned int i = 0; src[i] != '\0' ; i++)
 {
 if ( src[i] < 127 )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - hwpfilter/source

2018-01-29 Thread Caolán McNamara
 hwpfilter/source/hiodev.cxx |   24 +++-
 hwpfilter/source/hiodev.h   |6 +++---
 2 files changed, 14 insertions(+), 16 deletions(-)

New commits:
commit 9727b98f2f8b018f2ee9cc9628a7418146cc02bd
Author: Caolán McNamara 
Date:   Fri Jan 26 11:51:43 2018 +

ofz: check state in readblock

and change state to a bool and reuse it more

Change-Id: Iaa46004b144836431dd386a68a8ab688fd1477f2
Reviewed-on: https://gerrit.libreoffice.org/48687
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 

diff --git a/hwpfilter/source/hiodev.cxx b/hwpfilter/source/hiodev.cxx
index 91477a265d72..63403e91bdc4 100644
--- a/hwpfilter/source/hiodev.cxx
+++ b/hwpfilter/source/hiodev.cxx
@@ -142,13 +142,11 @@ void HStreamIODev::flush()
 gz_flush(_gzfp, Z_FINISH);
 }
 
-
-int HStreamIODev::state() const
+bool HStreamIODev::state() const
 {
-return 0;
+return false;
 }
 
-
 /* zlib 관련 부분 */
 bool HStreamIODev::setCompressed(bool flag)
 {
@@ -288,16 +286,14 @@ void HMemIODev::flush()
 {
 }
 
-
-int HMemIODev::state() const
+bool HMemIODev::state() const
 {
 if (pos <= length)
-return 0;
+return false;
 else
-return -1;
+return true;
 }
 
-
 bool HMemIODev::setCompressed(bool )
 {
 return false;
@@ -306,7 +302,7 @@ bool HMemIODev::setCompressed(bool )
 bool HMemIODev::read1b(unsigned char )
 {
 ++pos;
-if (pos <= length)
+if (!state())
 {
 out = ptr[pos - 1];
 return true;
@@ -326,7 +322,7 @@ bool HMemIODev::read1b(char )
 bool HMemIODev::read2b(unsigned short )
 {
 pos += 2;
-if (pos <= length)
+if (!state())
 {
  out = ptr[pos - 1] << 8 | ptr[pos - 2];
  return true;
@@ -337,7 +333,7 @@ bool HMemIODev::read2b(unsigned short )
 bool HMemIODev::read4b(unsigned int )
 {
 pos += 4;
-if (pos <= length)
+if (!state())
 {
 out = static_cast(ptr[pos - 1] << 24 | ptr[pos - 2] << 
16 |
 ptr[pos - 3] << 8 | ptr[pos - 4]);
@@ -357,6 +353,8 @@ bool HMemIODev::read4b(int )
 
 size_t HMemIODev::readBlock(void *p, size_t size)
 {
+if (state())
+return 0;
 if (length < pos + size)
 size = length - pos;
 memcpy(p, ptr + pos, size);
@@ -366,7 +364,7 @@ size_t HMemIODev::readBlock(void *p, size_t size)
 
 size_t HMemIODev::skipBlock(size_t size)
 {
-if (length < pos + size)
+if (state() || length < pos + size)
 return 0;
 pos += size;
 return size;
diff --git a/hwpfilter/source/hiodev.h b/hwpfilter/source/hiodev.h
index af49703c3482..e47bd8b2d0f0 100644
--- a/hwpfilter/source/hiodev.h
+++ b/hwpfilter/source/hiodev.h
@@ -47,7 +47,7 @@ class DLLEXPORT HIODev
 
 virtual bool open() = 0;
 virtual void flush() = 0;
-virtual int  state() const = 0;
+virtual bool state() const = 0;
 /* gzip routine wrapper */
 virtual bool setCompressed( bool ) = 0;
 
@@ -92,7 +92,7 @@ class HStreamIODev final: public HIODev
 /**
  * Not implemented.
  */
-virtual int  state() const override;
+virtual bool state() const override;
 /**
  * Set whether the stream is compressed or not
  */
@@ -144,7 +144,7 @@ class HMemIODev final: public HIODev
 
 virtual bool open() override;
 virtual void flush() override;
-virtual int  state() const override;
+virtual bool state() const override;
 /* gzip routine wrapper */
 virtual bool setCompressed( bool ) override;
 using HIODev::read1b;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits