[Libreoffice-commits] core.git: hwpfilter/source

2023-11-30 Thread Stephan Bergmann (via logerrit)
 hwpfilter/source/hwpeq.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit baf36dc7caa10365f3dda87bc2dd6e85e0333e98
Author: Stephan Bergmann 
AuthorDate: Wed Nov 29 18:02:22 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Nov 30 09:53:24 2023 +0100

Extended loplugin:ostr: hwpfilter

Change-Id: I1cd5359c192897d3d497eec977de10cedcc8f7b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160120
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/hwpfilter/source/hwpeq.cxx b/hwpfilter/source/hwpeq.cxx
index 3b078c81eb21..36c407ca3e18 100644
--- a/hwpfilter/source/hwpeq.cxx
+++ b/hwpfilter/source/hwpeq.cxx
@@ -534,9 +534,9 @@ static int next_token(OString , OString , 
std::istream *strm)
   token = buf;
 }
 if( token == "sub" || token == "from" )
-  token = "_";
+  token = "_"_ostr;
 if( token == "sup" || token == "to" )
-  token = "^";
+  token = "^"_ostr;
   }
   else if( IS_BINARY(ch) ) {
 do


[Libreoffice-commits] core.git: hwpfilter/source

2023-10-19 Thread Stephan Bergmann (via logerrit)
 hwpfilter/source/hwpreader.cxx |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit f290768698b24e0d4e7cbf29d6255dc083f02001
Author: Stephan Bergmann 
AuthorDate: Thu Oct 19 10:30:17 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Oct 19 23:20:14 2023 +0200

Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: hwpfilter

Change-Id: I49a08f7102ad6669a5f307c412d07a8040249b12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158201
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 8ff1ba1d7541..450e582ca504 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -45,7 +45,7 @@
 #include 
 
 // xmloff/xmlkyd.hxx
-constexpr OUStringLiteral sXML_CDATA = u"CDATA";
+constexpr OUString sXML_CDATA = u"CDATA"_ustr;
 
 namespace
 {
@@ -53,7 +53,7 @@ double WTI(double x) { return x / 1800.; } // unit => inch
 double WTMM(double x) { return x / 1800. * 25.4; } // unit => mm
 int WTSM(double x) { return x / 1800. * 2540; } // unit ==> 1/100 mm
 
-constexpr OUStringLiteral sBeginOfDoc(u"[\uBB38\uC11C\uC758 \uCC98\uC74C]");
+constexpr OUString sBeginOfDoc(u"[\uBB38\uC11C\uC758 \uCC98\uC74C]"_ustr);
 // U+BB38 HANGUL SYLLABLE MUN, U+C11C HANGUL SYLLABLE SEO,
 // U+C758 HANGUL SYLLABLE YI, U+CC98 HANGUL SYLLABLE CEO,
 // U+C74C HANGUL SYLLABLE EUM: "Begin of Document"
@@ -4719,8 +4719,8 @@ namespace
 {
 
 constexpr OUStringLiteral IMPLEMENTATION_NAME = 
u"com.sun.comp.hwpimport.HwpImportFilter";
-constexpr OUStringLiteral SERVICE_NAME1 = 
u"com.sun.star.document.ImportFilter";
-constexpr OUStringLiteral SERVICE_NAME2 = 
u"com.sun.star.document.ExtendedTypeDetection";
+constexpr OUString SERVICE_NAME1 = u"com.sun.star.document.ImportFilter"_ustr;
+constexpr OUString SERVICE_NAME2 = 
u"com.sun.star.document.ExtendedTypeDetection"_ustr;
 
 class HwpImportFilter : public WeakImplHelper< XFilter, XImporter, 
XServiceInfo, XExtendedFilterDetection >
 {


[Libreoffice-commits] core.git: hwpfilter/source

2023-10-03 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hbox.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit a235da83013bb9fccba29d87154aa93235a1c048
Author: Caolán McNamara 
AuthorDate: Tue Oct 3 09:14:45 2023 +0100
Commit: Caolán McNamara 
CommitDate: Tue Oct 3 12:13:16 2023 +0200

ofz#62935 avoid negative numbers in olHanglJaso

Change-Id: I3898b95e9d2fe60690889ba259859ed9f66636d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157512
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index b3bbc43c0b12..855b73e25c6c 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -431,7 +431,7 @@ hchar_string MailMerge::GetString()
 #define OL_HANGL_JASO   0
 #define OL_HANGL_KANATA 1
 
-static hchar olHanglJaso(int num, int type)
+static hchar olHanglJaso(unsigned int num, int type)
 {
 static const unsigned char han_init[] =
 { 0x88, 0x90, 0x94, 0x9c, 0xa0, 0xa4, 0xac, 0xb4, 0xb8, 0xc0, 0xc4, 
0xc8, 0xcc, 0xd0 };


[Libreoffice-commits] core.git: hwpfilter/source

2023-04-30 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 538956c32b867102b5174add3ea1990ae9d0b075
Author: Caolán McNamara 
AuthorDate: Sat Apr 29 19:56:46 2023 +0100
Commit: Caolán McNamara 
CommitDate: Sun Apr 30 10:58:48 2023 +0200

ofz#58400 Timeout

Change-Id: I6ded0d0613b66f7ec075796e257d93cf25822d2b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151189
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 302ebf7599f8..8ff1ba1d7541 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -1476,6 +1476,12 @@ void HwpReader::makePageStyle()
  HWPInfo& hwpinfo = hwpfile.GetHWPInfo();
  int pmCount = hwpfile.getColumnCount();
 
+ if (pmCount > 512 && utl::ConfigManager::IsFuzzing())
+ {
+ SAL_WARN("filter.hwp", "too many pages: " << pmCount << " clip to " 
<< 512);
+ pmCount = 512;
+ }
+
  for( int i = 0 ; i < pmCount ; i++ ){
  mxList->addAttribute("style:name", sXML_CDATA, "pm" + 
OUString::number(i + 1));
  startEl("style:page-master");


[Libreoffice-commits] core.git: hwpfilter/source

2023-03-20 Thread MoazAlaa (via logerrit)
 hwpfilter/source/grammar.h |   62 +++-
 hwpfilter/source/lexer.cxx |   76 ++---
 2 files changed, 71 insertions(+), 67 deletions(-)

New commits:
commit 9b631efd012c94d099b0181c5d85aed321d031f5
Author: MoazAlaa 
AuthorDate: Sun Mar 5 01:10:28 2023 +0200
Commit: Andreas Heinisch 
CommitDate: Mon Mar 20 13:23:00 2023 +

tdf#145614 convert all #define into enum in hwpfilter/source/grammar.h

Change-Id: I8496b95cc55732d72d36cfc4d2fadc5cbea53e6a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148261
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/hwpfilter/source/grammar.h b/hwpfilter/source/grammar.h
index 4d69482cd04e..e18a8445590c 100644
--- a/hwpfilter/source/grammar.h
+++ b/hwpfilter/source/grammar.h
@@ -22,35 +22,39 @@ typedef union {
 const char *str;
 Node *ptr;
 } YYSTYPE;
-#define ACCENT  257
-#define SMALL_GREEK 258
-#define CAPITAL_GREEK   259
-#define BINARY_OPERATOR 260
-#define RELATION_OPERATOR   261
-#define ARROW   262
-#define GENERAL_IDEN263
-#define GENERAL_OPER264
-#define BIG_SYMBOL  265
-#define FUNCTION266
-#define ROOT267
-#define FRACTION268
-#define SUBSUP  269
-#define EQOVER  270
-#define DELIMETER   271
-#define LARGE_DELIM 272
-#define DECORATION  273
-#define SPACE_SYMBOL274
-#define CHARACTER   275
-#define STRING  276
-#define OPERATOR277
-#define EQBEGIN 278
-#define EQEND   279
-#define EQLEFT  280
-#define EQRIGHT 281
-#define NEWLINE 282
-#define LEFT_DELIM  283
-#define RIGHT_DELIM 284
-#define DIGIT   285
+
+enum Grammar
+{
+ACCENT  = 257,
+SMALL_GREEK = 258,
+CAPITAL_GREEK   = 259,
+BINARY_OPERATOR = 260,
+RELATION_OPERATOR   = 261,
+ARROW   = 262,
+GENERAL_IDEN= 263,
+GENERAL_OPER= 264,
+BIG_SYMBOL  = 265,
+FUNCTION= 266,
+ROOT= 267,
+FRACTION= 268,
+SUBSUP  = 269,
+EQOVER  = 270,
+DELIMETER   = 271,
+LARGE_DELIM = 272,
+DECORATION  = 273,
+SPACE_SYMBOL= 274,
+CHARACTER   = 275,
+STRING  = 276,
+OPERATOR= 277,
+EQBEGIN = 278,
+EQEND   = 279,
+EQLEFT  = 280,
+EQRIGHT = 281,
+NEWLINE = 282,
+LEFT_DELIM  = 283,
+RIGHT_DELIM = 284,
+DIGIT   = 285,
+};
 
 extern YYSTYPE yylval;
 
diff --git a/hwpfilter/source/lexer.cxx b/hwpfilter/source/lexer.cxx
index 5f28ff2eeaa5..cb6ae3fc4b49 100644
--- a/hwpfilter/source/lexer.cxx
+++ b/hwpfilter/source/lexer.cxx
@@ -1166,91 +1166,91 @@ do_action:  /* This label is used only to access EOF 
actions. */
 
 case 1:
 YY_RULE_SETUP
-{ yylval.str = yytext+1; token_debug("  ==>Begin[%s]\n",yytext+1); return 
EQBEGIN; }
+{ yylval.str = yytext+1; token_debug("  ==>Begin[%s]\n",yytext+1); return 
Grammar::EQBEGIN; }
 //YY_BREAK
 case 2:
 YY_RULE_SETUP
-{ yylval.str = yytext+1; token_debug("  ==>End[%s]\n",yytext+1); return EQEND; 
}
+{ yylval.str = yytext+1; token_debug("  ==>End[%s]\n",yytext+1); return 
Grammar::EQEND; }
 //YY_BREAK
 case 3:
 YY_RULE_SETUP
-{ yylval.str = yytext+1; token_debug("  ==>Left[%s]\n",yytext+1); return 
EQLEFT; }
+{ yylval.str = yytext+1; token_debug("  ==>Left[%s]\n",yytext+1); return 
Grammar::EQLEFT; }
 //YY_BREAK
 case 4:
 YY_RULE_SETUP
-{ yylval.str = yytext+1; token_debug("  ==>LeftDelim[%s]\n",yytext+1); return 
LEFT_DELIM; }
+{ yylval.str = yytext+1; token_debug("  ==>LeftDelim[%s]\n",yytext+1); return 
Grammar::LEFT_DELIM; }
 //YY_BREAK
 case 5:
 YY_RULE_SETUP
-{ yylval.str = yytext+1; token_debug("  ==>RightDelim[%s]\n",yytext+1); return 
RIGHT_DELIM; }
+{ yylval.str = yytext+1; token_debug("  ==>RightDelim[%s]\n",yytext+1); return 
Grammar::RIGHT_DELIM; }
 //YY_BREAK
 case 6:
 YY_RULE_SETUP
-{ yylval.str = yytext+1; token_debug("  ==>Right[%s]\n",yytext+1); return 
EQRIGHT; }
+{ yylval.str = yytext+1; token_debug("  ==>Right[%s]\n",yytext+1); return 
Grammar::EQRIGHT; }
 //YY_BREAK
 case 7:
 YY_RULE_SETUP
-{ yylval.str = yytext;   token_debug("  ==>NewLine[%s]\n",yytext); return 
NEWLINE; }
+{ yylval.str = yytext;   token_debug("  ==>NewLine[%s]\n",yytext); return 
Grammar::NEWLINE; }
 //YY_BREAK
 case 8:
 YY_RULE_SETUP
-{ yylval.str = yytext+1; token_debug("  ==>Accent[%s]\n",yytext+1); return 
ACCENT; }
+{ yylval.str = yytext+1; token_debug("  ==>Accent[%s]\n",yytext+1); return 
Grammar::ACCENT; }
 //YY_BREAK
 case 9:
 YY_RULE_SETUP
-{ yylval.str = yytext+1; token_debug("  ==>Small_Greek[%s]\n",yytext+1); 
return SMALL_GREEK; }
+{ yylval.str = yytext+1; token_debug("  ==>Small_Greek[%s]\n",yytext+1); 
return Grammar::SMALL_GREEK; }
 //YY_BREAK
 case 10:
 YY_RULE_SETUP
-{ yylval.str = yytext+1; token_debug("  

[Libreoffice-commits] core.git: hwpfilter/source

2023-03-15 Thread Stephan Bergmann (via logerrit)
 hwpfilter/source/hstyle.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 5d323ee3c765a8767f988d8a7cc26466d0019d20
Author: Stephan Bergmann 
AuthorDate: Tue Mar 14 22:37:43 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Mar 15 07:59:31 2023 +

Silence a false warning also for GCC 13

...as it still hits at least with gcc-c++-13.0.1-0.7.fc38.x86_64

Change-Id: I25f48c241cec17d277c2ff6d4216ee63fdcfc6e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148901
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/hwpfilter/source/hstyle.cxx b/hwpfilter/source/hstyle.cxx
index bf4538d686db..013f755496a5 100644
--- a/hwpfilter/source/hstyle.cxx
+++ b/hwpfilter/source/hstyle.cxx
@@ -68,14 +68,14 @@ void HWPStyle::SetName(int n, char const* name)
 
 if (name)
 {
-#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 12) && !defined __clang__
+#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 13) && !defined __clang__
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wstringop-truncation"
 #endif
 auto const p = style[n].name;
 strncpy(p, name, MAXSTYLENAME);
 p[MAXSTYLENAME] = '\0'; // just in case, even though the array is 
zero-initialized
-#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 12) && !defined __clang__
+#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 13) && !defined __clang__
 #pragma GCC diagnostic pop
 #endif
 }


[Libreoffice-commits] core.git: hwpfilter/source

2023-02-10 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hbox.cxx |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit d6b590feda1c61fd5ed14c0be66379b8e5de0c6a
Author: Caolán McNamara 
AuthorDate: Fri Feb 10 15:02:52 2023 +
Commit: Caolán McNamara 
CommitDate: Sat Feb 11 00:10:51 2023 +

ofz: Use-of-uninitialized-value

Change-Id: I033fab3ea016d3b57891a35602920b7de811ccb4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146784
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index 3b740999b560..47d18e76fc1e 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -579,10 +579,11 @@ OUString Outline::GetUnicode() const
 case OLSTY_NUMS2:
 {
 OStringBuffer buf;
-int i;
-
-for (i = 0; i <= level; i++)
+for (unsigned int i = 0; i <= level; ++i)
 {
+if (i >= std::size(number))
+break;
+
 levelnum = ((number[i] < 1) ? 1 : number[i]);
 buf.append(OString::number(levelnum));
 if (!(shape == OLSTY_NUMS2 && i && i == level))


[Libreoffice-commits] core.git: hwpfilter/source

2023-02-10 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hbox.cxx |1 -
 1 file changed, 1 deletion(-)

New commits:
commit e43062523b53f7c472f4c0183d333b34cf7adbdf
Author: Caolán McNamara 
AuthorDate: Fri Feb 10 14:56:15 2023 +
Commit: Caolán McNamara 
CommitDate: Fri Feb 10 18:21:26 2023 +

operator [] out of range assert

presumably since:

commit 0e45f8318ee73361fecb049b33b0662fabe295d3
Date:   Sat Nov 5 15:59:27 2022 +0100

-Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): hwpfilter

Change-Id: I1e93526d46d1357a8f11f7ff7ed4c3f2274b9c7a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146783
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index b498fa31cfbb..3b740999b560 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -581,7 +581,6 @@ OUString Outline::GetUnicode() const
 OStringBuffer buf;
 int i;
 
-buf[0] = 0;
 for (i = 0; i <= level; i++)
 {
 levelnum = ((number[i] < 1) ? 1 : number[i]);


[Libreoffice-commits] core.git: hwpfilter/source

2023-02-08 Thread Devansh Jain (via logerrit)
 hwpfilter/source/fontmap.hxx   |5 --
 hwpfilter/source/grammar.hxx   |5 --
 hwpfilter/source/hwpreader.hxx |   77 +++--
 3 files changed, 39 insertions(+), 48 deletions(-)

New commits:
commit 81fa02eedbda2afa34c82420a02cd3b3f825be06
Author: Devansh Jain 
AuthorDate: Sat Feb 4 17:07:28 2023 +0530
Commit: Ilmari Lauhakangas 
CommitDate: Thu Feb 9 06:26:18 2023 +

tdf#143148 Use pragma once instead of include guards in hwpfilter

Change-Id: I010b6c76c1f859340f544409bbaab946cf2a6aa2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146554
Tested-by: Jenkins
Tested-by: Ilmari Lauhakangas 
Reviewed-by: Ilmari Lauhakangas 

diff --git a/hwpfilter/source/fontmap.hxx b/hwpfilter/source/fontmap.hxx
index 3ab2e0849e1d..1debe8ede2bd 100644
--- a/hwpfilter/source/fontmap.hxx
+++ b/hwpfilter/source/fontmap.hxx
@@ -17,13 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_HWPFILTER_SOURCE_FONTMAP_HXX
-#define INCLUDED_HWPFILTER_SOURCE_FONTMAP_HXX
+#pragma once
 
 #include 
 
 int getRepFamilyName(char const*, char*, double&);
 
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/grammar.hxx b/hwpfilter/source/grammar.hxx
index a4a2e39cb0bb..041b4606a530 100644
--- a/hwpfilter/source/grammar.hxx
+++ b/hwpfilter/source/grammar.hxx
@@ -17,8 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_HWPFILTER_SOURCE_GRAMMAR_HXX
-#define INCLUDED_HWPFILTER_SOURCE_GRAMMAR_HXX
+#pragma once
 
 #include 
 
@@ -26,6 +25,4 @@ class Node;
 
 Node* mainParse(char const* _code);
 
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hwpreader.hxx b/hwpfilter/source/hwpreader.hxx
index 0cb9e62c0c19..d99099f2b31c 100644
--- a/hwpfilter/source/hwpreader.hxx
+++ b/hwpfilter/source/hwpreader.hxx
@@ -17,8 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_HWPFILTER_SOURCE_HWPREADER_HXX
-#define INCLUDED_HWPFILTER_SOURCE_HWPREADER_HXX
+#pragma once
 
 #include 
 
@@ -77,7 +76,6 @@ struct HwpReaderPrivate;
  */
 class HwpReader : public WeakImplHelper
 {
-
 public:
 HwpReader();
 virtual ~HwpReader() override;
@@ -86,24 +84,26 @@ public:
 /**
  * parseStream does Parser-startup initializations
  */
-virtual sal_Bool SAL_CALL filter(const Sequence< PropertyValue >& 
aDescriptor) override;
+virtual sal_Bool SAL_CALL filter(const Sequence& 
aDescriptor) override;
 virtual void SAL_CALL cancel() override {}
-void setDocumentHandler(Reference< XDocumentHandler > const & xHandler)
+void setDocumentHandler(Reference const& xHandler)
 {
 m_rxDocumentHandler = xHandler;
 }
 
 bool importHStream(std::unique_ptr stream);
+
 private:
-Reference< XDocumentHandler > m_rxDocumentHandler;
+Reference m_rxDocumentHandler;
 rtl::Reference mxList;
 HWPFile hwpfile;
 std::unique_ptr d;
+
 private:
 /*  Document Parsing - */
 void makeMeta();
 void makeStyles();
-void makeDrawMiscStyle(HWPDrawingObject *);
+void makeDrawMiscStyle(HWPDrawingObject*);
 void makeAutoStyles();
 void makeMasterStyles();
 void makeBody();
@@ -111,45 +111,45 @@ private:
 void makeTextDecls();
 
 /*  Paragraph Parsing - */
-void parsePara(HWPPara *para);
-void make_text_p0(HWPPara *para, bool bParaStart);
-void make_text_p1(HWPPara *para, bool bParaStart);
-void make_text_p3(HWPPara *para, bool bParaStart);
+void parsePara(HWPPara* para);
+void make_text_p0(HWPPara* para, bool bParaStart);
+void make_text_p1(HWPPara* para, bool bParaStart);
+void make_text_p3(HWPPara* para, bool bParaStart);
 
 /*  rDocument->characters(x) - */
-void makeChars(hchar_string & rStr);
+void makeChars(hchar_string& rStr);
 
 /*  Special Char Parsing - */
-void makeFieldCode(hchar_string const & rStr, FieldCode const *hbox); //6
-void makeBookmark(Bookmark const *hbox);  //6
-void makeDateFormat(DateCode *hbox);//7
-void makeDateCode(DateCode *hbox);  //8
-void makeTab();//9
-void makeTable(TxtBox *hbox);
-void makeTextBox(TxtBox *hbox);
-void makeFormula(TxtBox *hbox);
-void makeHyperText(TxtBox *hbox);
-void makePicture(Picture *hbox);
-void makePictureDRAW(HWPDrawingObject *drawobj, const Picture *hbox);
+void makeFieldCode(hchar_string const& rStr, FieldCode const* hbox); //6
+void makeBookmark(Bookmark const* hbox); //6
+void makeDateFormat(DateCode* hbox); //7
+void makeDateCode(DateCode* hbox); //8
+void makeTab(); //9
+void makeTable(TxtBox* hbox);
+void makeTextBox(TxtBox* hbox);
+void makeFormula(TxtBox* hbox);
+void makeHyperText(TxtBox* hbox);
+void 

[Libreoffice-commits] core.git: hwpfilter/source

2023-02-07 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hbox.cxx |   15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

New commits:
commit ca57cee2ae5718378193a9c7050248c63b5fa47e
Author: Caolán McNamara 
AuthorDate: Mon Feb 6 19:58:40 2023 +
Commit: Caolán McNamara 
CommitDate: Tue Feb 7 09:32:59 2023 +

ofz#55751 check that level is valid

Change-Id: I971bdcc62fd3775f8f75bf69db41182afc4baefc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146595
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index 16236bb8fc41..b498fa31cfbb 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -467,7 +467,7 @@ static hchar olHanglJaso(int num, int type)
 
 static const hchar *GetOutlineStyleChars(int style)
 {
-static const hchar out_bul_style_entry[5][8] =  // extern
+static const hchar out_bul_style_entry[5][MAX_OUTLINE_LEVEL+1] = // extern
 {
 { // 0 OLSTY_BULLET1
 0x2f18, 0x2f12, 0x2f08, 0x2f02, 0x2f06, 0x2f00, 0x2043, 0x
@@ -482,7 +482,7 @@ static const hchar *GetOutlineStyleChars(int style)
 0x2f18, 0x2f16, 0x2f12, 0x2f10, 0x2f06, 0x2f00, 0x2043, 0x
 },
 {
-0xAC61, 0xB677, 0xB861, 0xB8F7, 0xB781, 0x
+0xAC61, 0xB677, 0xB861, 0xB8F7, 0xB781, 0x, 0x, 0x
 },
 };
 if (style >= OLSTY_BULLET1 && style <= OLSTY_BULLET5)
@@ -605,12 +605,15 @@ OUString Outline::GetUnicode() const
 case OLSTY_BULLET3:
 case OLSTY_BULLET4:
 case OLSTY_BULLET5:
+{
+if (level < MAX_OUTLINE_LEVEL)
 {
-p = GetOutlineStyleChars(shape);
-buffer[0] = p[level];
-buffer[1] = 0;
-return hstr2OUString(buffer);
+p = GetOutlineStyleChars(shape);
+buffer[0] = p[level];
+buffer[1] = 0;
 }
+return hstr2OUString(buffer);
+}
 case OLSTY_USER:
 case OLSTY_BULUSER:
 {


[Libreoffice-commits] core.git: hwpfilter/source

2023-02-04 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/htags.cxx |5 ++---
 hwpfilter/source/htags.h   |3 ++-
 hwpfilter/source/hwpreader.cxx |4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit f71ce9b35598d6aa64f3b095e0b3c7683948c280
Author: Caolán McNamara 
AuthorDate: Sat Feb 4 17:14:36 2023 +
Commit: Caolán McNamara 
CommitDate: Sat Feb 4 22:54:28 2023 +

ofz: Use-of-uninitialized-value

Change-Id: I97fb4edcad3a014b622f1a936adecd634121ad3f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146559
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx
index 51fbd9b539a2..69d0398ca952 100644
--- a/hwpfilter/source/htags.cxx
+++ b/hwpfilter/source/htags.cxx
@@ -52,9 +52,8 @@ bool HyperText::Read(HWPFile& hwpf)
 
 EmPicture::EmPicture(size_t tsize)
 : size(tsize >= 32 ? tsize - 32 : 0)
+, data(size, 0)
 {
-if (size != 0)
-data.reset( new uchar[size] );
 }
 
 EmPicture::~EmPicture()
@@ -70,7 +69,7 @@ bool EmPicture::Read(HWPFile & hwpf)
 name[0] = 'H';
 name[1] = 'W';
 name[2] = 'P';
-return hwpf.ReadBlock(data.get(), size) != 0;
+return hwpf.ReadBlock(data.data(), size) != 0;
 }
 
 
diff --git a/hwpfilter/source/htags.h b/hwpfilter/source/htags.h
index 0a302bf188af..d662a002ecb3 100644
--- a/hwpfilter/source/htags.h
+++ b/hwpfilter/source/htags.h
@@ -21,6 +21,7 @@
 #define INCLUDED_HWPFILTER_SOURCE_HTAGS_H
 
 #include 
+#include 
 #ifdef _WIN32
 #include 
 #endif
@@ -34,7 +35,7 @@ struct EmPicture
 size_t size;
 char name[16];
 char type[16];
-std::unique_ptr data;
+std::vector data;
 
 explicit EmPicture(size_t size);
 ~EmPicture(void);
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 3cab4cb9ba72..302ebf7599f8 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -510,7 +510,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 if (emp)
 {
 startEl("office:binary-data");
-chars(base64_encode_string(emp->data.get(), emp->size));
+chars(base64_encode_string(emp->data.data(), emp->size));
 endEl("office:binary-data");
 }
 endEl("draw:fill-image");
@@ -3824,7 +3824,7 @@ void HwpReader::makePicture(Picture * hbox)
  EmPicture *emp = hwpfile.GetEmPicture(hbox);
  if( emp )
  {
- chars(base64_encode_string(emp->data.get(), 
emp->size));
+ chars(base64_encode_string(emp->data.data(), 
emp->size));
  }
 }
 else{


[Libreoffice-commits] core.git: hwpfilter/source

2023-01-30 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hbox.cxx |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit e783208906611238a9a6ce9d14029eb732fc611d
Author: Caolán McNamara 
AuthorDate: Mon Jan 30 09:15:17 2023 +
Commit: Caolán McNamara 
CommitDate: Mon Jan 30 16:56:54 2023 +

ofz#55520 check level is < MAX_OUTLINE_LEVEL

Change-Id: I61ac10f40cd754a1ea3186ab89e9bfd1e99dc563
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146340
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index acf6770ec9ba..16236bb8fc41 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -595,10 +595,11 @@ OUString Outline::GetUnicode() const
 case OLSTY_NUMSIG1:
 case OLSTY_NUMSIG2:
 case OLSTY_NUMSIG3:
-{
-getOutlineNumStr(shape, level, number[level], buffer);
+{
+if (level < std::size(number))
+getOutlineNumStr(shape, level, number[level], buffer);
 return hstr2OUString(buffer);
-}
+}
 case OLSTY_BULLET1:
 case OLSTY_BULLET2:
 case OLSTY_BULLET3:


[Libreoffice-commits] core.git: hwpfilter/source

2022-12-20 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hbox.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit f6b4c3fb68f9b36e1e64fc4a4c680ab1bb7fb013
Author: Caolán McNamara 
AuthorDate: Mon Dec 19 21:19:40 2022 +
Commit: Caolán McNamara 
CommitDate: Tue Dec 20 08:22:07 2022 +

cid#1517796 Out-of-bounds read

Change-Id: I930e3888cfa3363b9183619225f0d4cdca197cdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144547
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index 2e43d0f19691..acf6770ec9ba 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -616,7 +616,7 @@ OUString Outline::GetUnicode() const
 char dest[80];
 int l = 0;
 unsigned i = level;
-if( deco[i][0] ){
+if (i < std::size(deco) && deco[i][0]) {
 buffer[l++] = deco[i][0];
 }
 if (i < std::size(user_shape))
@@ -690,7 +690,7 @@ OUString Outline::GetUnicode() const
 break;
 }
 }
-if( deco[i][1] ){
+if (i < std::size(deco) && deco[i][1]) {
 buffer[l++] = deco[i][1];
 }
 buffer[l] = 0;


[Libreoffice-commits] core.git: hwpfilter/source

2022-11-24 Thread Stephan Bergmann (via logerrit)
 hwpfilter/source/hwpfile.cxx   |   10 ++
 hwpfilter/source/hwpfile.h |1 +
 hwpfilter/source/hwplib.h  |2 +-
 hwpfilter/source/hwpreader.cxx |   16 
 4 files changed, 20 insertions(+), 9 deletions(-)

New commits:
commit 46eb2fa586b683858dc35cc535e0f30108b1cdbe
Author: Stephan Bergmann 
AuthorDate: Thu Nov 24 13:48:30 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Nov 24 17:37:21 2022 +0100

hwpfilter: Fix use of std::char_trait

...now that it is gone from libc++ 16 trunk since


"[libc++] Remove default definition of std::char_traits", causing

> In file included from hwpfilter/source/formula.cxx:20:
> In file included from hwpfilter/source/formula.h:23:
> In file included from 
workdir/UnoApiHeadersTarget/offapi/normal/com/sun/star/xml/sax/XDocumentHandler.hpp:6:
> In file included from 
workdir/UnoApiHeadersTarget/offapi/normal/com/sun/star/xml/sax/XDocumentHandler.hdl:6:
> In file included from 
workdir/UnoApiHeadersTarget/udkapi/normal/com/sun/star/uno/XInterface.hdl:6:
> In file included from include/com/sun/star/uno/Any.h:30:
> In file included from include/rtl/ustring.hxx:34:
> In file included from ~/llvm/inst/bin/../include/c++/v1/ostream:170:
> In file included from ~/llvm/inst/bin/../include/c++/v1/bitset:131:
> ~/llvm/inst/bin/../include/c++/v1/string:676:46: error: implicit 
instantiation of undefined template 'std::char_traits'
> static_assert(( is_same<_CharT, typename 
traits_type::char_type>::value),
>  ^
> hwpfilter/source/hwplib.h:47:10: note: in instantiation of template class 
'std::basic_string' requested here
> if (s.length() > 
o3tl::make_unsigned(std::numeric_limits::max())) {
>  ^
> ~/llvm/inst/bin/../include/c++/v1/__fwd/string.h:22:29: note: template is 
declared here
> struct _LIBCPP_TEMPLATE_VIS char_traits;
> ^

Change-Id: Ied437a079cb66c8b49f9980ab29b59ec5e2097d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143238
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index f9d5b3ab6008..637489aee04b 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -139,6 +139,16 @@ bool HWPFile::Read2b(unsigned short )
 return hiodev && hiodev->read2b(out);
 }
 
+bool HWPFile::Read2b(char16_t )
+{
+unsigned short n;
+auto const ok = Read2b(n);
+if (ok) {
+out = n;
+}
+return ok;
+}
+
 bool HWPFile::Read4b(unsigned int )
 {
 return hiodev && hiodev->read4b(out);
diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h
index 72d22a5aeb95..2c4d7e7bdc9e 100644
--- a/hwpfilter/source/hwpfile.h
+++ b/hwpfilter/source/hwpfile.h
@@ -130,6 +130,7 @@ class DLLEXPORT HWPFile
  * Reads two byte from HIODev
  */
 bool Read2b(unsigned short );
+bool Read2b(char16_t );
 /**
  * Reads four byte from HIODev
  */
diff --git a/hwpfilter/source/hwplib.h b/hwpfilter/source/hwplib.h
index ec438d36134e..48c0cb4a3146 100644
--- a/hwpfilter/source/hwplib.h
+++ b/hwpfilter/source/hwplib.h
@@ -33,7 +33,7 @@
 /**
  * size of hunit is 4 since hwp96 version
  */
-typedef unsigned short  hchar;
+typedef char16_t  hchar;
 typedef int hunit;
 typedef unsigned char   kchar;
 
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 5db11d92b848..3cab4cb9ba72 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -239,21 +239,21 @@ void HwpReader::makeMeta()
 if (hwpinfo.summary.title[0])
 {
 startEl("dc:title");
-chars(hstr2OUString(hwpinfo.summary.title));
+chars(hstr2OUString(reinterpret_cast(hwpinfo.summary.title)));
 endEl("dc:title");
 }
 
 if (hwpinfo.summary.subject[0])
 {
 startEl("dc:subject");
-chars(hstr2OUString(hwpinfo.summary.subject));
+chars(hstr2OUString(reinterpret_cast(hwpinfo.summary.subject)));
 endEl("dc:subject");
 }
 
 if (hwpinfo.summary.author[0])
 {
 startEl("meta:initial-creator");
-chars(hstr2OUString(hwpinfo.summary.author));
+chars(hstr2OUString(reinterpret_cast(hwpinfo.summary.author)));
 endEl("meta:initial-creator");
 }
 
@@ -327,31 +327,31 @@ void HwpReader::makeMeta()
 if (hwpinfo.summary.keyword[0][0])
 {
 startEl("meta:keyword");
-chars(hstr2OUString(hwpinfo.summary.keyword[0]));
+chars(hstr2OUString(reinterpret_cast(hwpinfo.summary.keyword[0])));
 endEl("meta:keyword");
 }
 if (hwpinfo.summary.keyword[1][0])
 {
 startEl("meta:keyword");
-

[Libreoffice-commits] core.git: hwpfilter/source

2022-11-06 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 64f42fe944cff92353c6900f813114ae41d132aa
Author: Caolán McNamara 
AuthorDate: Sun Nov 6 12:31:14 2022 +
Commit: Caolán McNamara 
CommitDate: Sun Nov 6 14:15:25 2022 +0100

ofz#52490 Timeout

Change-Id: I0aa462bea2975e6532dc3cd4b2f088d5dde8852f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142352
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 8ac31e29caa8..5db11d92b848 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -958,10 +958,10 @@ void HwpReader::makeMasterStyles()
 PageSetting *pPrevSet = nullptr;
 PageSetting *pPage = nullptr;
 
-if (nMax > 2048 && utl::ConfigManager::IsFuzzing())
+if (nMax > 512 && utl::ConfigManager::IsFuzzing())
 {
-SAL_WARN("filter.hwp", "too many pages: " << nMax << " clip to " << 
2048);
-nMax = 2048;
+SAL_WARN("filter.hwp", "too many pages: " << nMax << " clip to " << 
512);
+nMax = 512;
 }
 
 for( i = 1; i <= nMax ; i++ )


[Libreoffice-commits] core.git: hwpfilter/source

2022-11-05 Thread Stephan Bergmann (via logerrit)
 hwpfilter/source/hbox.cxx  |   38 -
 hwpfilter/source/hcode.cxx |4 -
 hwpfilter/source/hwpreader.cxx |   90 +
 hwpfilter/source/mzstring.cxx  |   17 ++-
 4 files changed, 80 insertions(+), 69 deletions(-)

New commits:
commit 0e45f8318ee73361fecb049b33b0662fabe295d3
Author: Stephan Bergmann 
AuthorDate: Sat Nov 5 15:59:27 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Sat Nov 5 18:27:21 2022 +0100

-Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): hwpfilter

Change-Id: I91aa4dc3cedccf341a5b7a936c171323a3e58630
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142327
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index ea8d46e5f59e..e72c61434fb7 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -29,7 +29,10 @@
 #include "hcode.h"
 #include "datecode.h"
 
+#include 
 #include 
+#include 
+#include 
 
 int HBox::boxCount = 0;
 
@@ -285,7 +288,7 @@ hchar_string DateCode::GetString()
 ret.push_back(*fmt);
 }
 if (num != -1)
-sprintf(cbuf, form, num);
+o3tl::sprintf(cbuf, form, num);
 for (i = 0; 0 != cbuf[i]; i++)
 {
 ret.push_back(*(cbuf + i));
@@ -519,9 +522,9 @@ static void getOutlineNumStr(int style, int level, int num, 
hchar * hstr)
 *hstr++ = '(';
 if (fmt & NUM)
 {
-sprintf(buf, "%d", num);
-str2hstr(buf, hstr);
-hstr += strlen(buf);
+auto const numbuf = OString::number(num);
+str2hstr(numbuf.getStr(), hstr);
+hstr += numbuf.length;
 }
 else if (fmt & (U_ROM | L_ROM))
 {
@@ -575,20 +578,18 @@ OUString Outline::GetUnicode() const
 case OLSTY_NUMS1:
 case OLSTY_NUMS2:
 {
-char cur_num_str[10], buf[80];
+OStringBuffer buf;
 int i;
 
 buf[0] = 0;
 for (i = 0; i <= level; i++)
 {
 levelnum = ((number[i] < 1) ? 1 : number[i]);
-if (shape == OLSTY_NUMS2 && i && i == level)
-sprintf(cur_num_str, "%d%c", levelnum, 0);
-else
-sprintf(cur_num_str, "%d%c", levelnum, '.');
-strcat(buf, cur_num_str);
+buf.append(OString::number(levelnum));
+if (!(shape == OLSTY_NUMS2 && i && i == level))
+buf.append('.');
 }
-str2hstr(buf, buffer);
+str2hstr(buf.getStr(), buffer);
 return hstr2OUString(buffer);
 }
 case OLSTY_NUMSIG1:
@@ -670,20 +671,17 @@ OUString Outline::GetUnicode() const
 break;
 case 12: /* Sequenced numbers. */
 {
- char cur_num_str[10],buf[80];
+ OStringBuffer buf;
  int j;
- buf[0] = 0;
  for (j = 0; j <= level; j++)
  {
   levelnum = ((number[j] < 1) ? 1 : number[j]);
-  if ((j && j == level) || (j == level && 
deco[i][1]))
-sprintf(cur_num_str, "%d%c", levelnum, 
0);
-  else
-sprintf(cur_num_str, "%d%c", levelnum, 
'.');
-  strcat(buf, cur_num_str);
+  buf.append(OString::number(levelnum));
+  if (!((j && j == level) || (j == level && 
deco[i][1])))
+buf.append('.');
  }
- str2hstr(buf, buffer + l);
- l += strlen(buf);
+ str2hstr(buf.getStr(), buffer + l);
+ l += buf.getLength();
  break;
 }
 default:
diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index cc9d051ca07b..d97387c54efe 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -31,12 +31,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
@@ -1296,7 +1296,7 @@ OUString hcolor2str(uchar color, uchar shade, bool 
bIsChar)
 OUString rgb2str(unsigned char red, unsigned char green, unsigned char blue)
 {
 char buf[8];
-int n = std::max(sprintf(buf, "#%02x%02x%02x", red, green, blue), 0);
+int n = std::max(o3tl::sprintf(buf, "#%02x%02x%02x", red, green, blue), 0);
 return 

[Libreoffice-commits] core.git: hwpfilter/source

2022-08-25 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 84629220ad7d7897f57070b4aba6a3cbaef756aa
Author: Caolán McNamara 
AuthorDate: Thu Aug 25 20:27:50 2022 +0100
Commit: Caolán McNamara 
CommitDate: Thu Aug 25 21:45:33 2022 +0200

ofz#47118 Timeout

Change-Id: I8bb03b567acd4419aff15267d936298378ca03d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138848
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index d2690082ce3b..58d9598c7af7 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -957,10 +957,10 @@ void HwpReader::makeMasterStyles()
 PageSetting *pPrevSet = nullptr;
 PageSetting *pPage = nullptr;
 
-if (nMax > SAL_MAX_UINT16 && utl::ConfigManager::IsFuzzing())
+if (nMax > 2048 && utl::ConfigManager::IsFuzzing())
 {
-SAL_WARN("filter.hwp", "too many pages: " << nMax << " clip to " << 
SAL_MAX_UINT16);
-nMax = SAL_MAX_UINT16;
+SAL_WARN("filter.hwp", "too many pages: " << nMax << " clip to " << 
2048);
+nMax = 2048;
 }
 
 for( i = 1; i <= nMax ; i++ )


[Libreoffice-commits] core.git: hwpfilter/source

2022-08-06 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit bd13bd144cfa00a52a056a95167c8510c84a0e40
Author: Caolán McNamara 
AuthorDate: Fri Aug 5 21:19:55 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sat Aug 6 13:06:40 2022 +0200

ofz#49832 Integer-overflow

Change-Id: I35efe0b78546b4804206f78159b2fc18172ca4f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137885
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index ab495315722c..73642b5d63f0 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -575,7 +575,8 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 }
 if( prop->angle > 0 && ( prop->gstyle == 1 || prop->gstyle == 
4))
 {
-int angle = 1800 - prop->angle * 10;
+auto normangle = prop->angle % 360;
+int angle = 1800 - normangle * 10;
 mxList->addAttribute( "draw:angle", sXML_CDATA, 
OUString::number(angle));
 }
 startEl("draw:gradient");


[Libreoffice-commits] core.git: hwpfilter/source

2022-07-24 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hpara.cxx |   18 +-
 hwpfilter/source/hpara.h   |   13 -
 2 files changed, 9 insertions(+), 22 deletions(-)

New commits:
commit 9a9d955f7bbcedb7921345a107f4aec5128c1c43
Author: Caolán McNamara 
AuthorDate: Sat Jul 23 20:40:33 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sun Jul 24 20:37:40 2022 +0200

ofz#49217 height_sp member, etc unused

massif peak from 37.10MB to 28.16MB

Change-Id: I3d773637cee4243f235a4784e29a066d2c8b747a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137384
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hpara.cxx b/hwpfilter/source/hpara.cxx
index 52e13b829744..4cddf7d76ad7 100644
--- a/hwpfilter/source/hpara.cxx
+++ b/hwpfilter/source/hpara.cxx
@@ -31,30 +31,30 @@
 
 void LineInfo::Read(HWPFile & hwpf, HWPPara const *pPara)
 {
-if (!hwpf.Read2b(pos))
-return;
 unsigned short tmp16;
 if (!hwpf.Read2b(tmp16))
 return;
-space_width = tmp16;
+// unused field is "pos" "Starting character position"
+if (!hwpf.Read2b(tmp16))
+return;
+// unused field is "space_width"
 if (!hwpf.Read2b(tmp16))
 return;
-height = tmp16;
-// internal information
+// unused field is "height"
+// internal information
 if (!hwpf.Read2b(tmp16))
 return;
 pgy = tmp16;
 if (!hwpf.Read2b(tmp16))
 return;
-sx = tmp16;
+// unused field is "sx"
 if (!hwpf.Read2b(tmp16))
 return;
-psx = tmp16;
+// unused field is "psx"
 if (!hwpf.Read2b(tmp16))
 return;
-pex = tmp16;
-height_sp = 0;
 
+hunit pex = tmp16;
 if( pex >> 15 & 0x01 )
 {
 if (pex & 0x01)
diff --git a/hwpfilter/source/hpara.h b/hwpfilter/source/hpara.h
index fcf1681715b7..53c35a2ccb7f 100644
--- a/hwpfilter/source/hpara.h
+++ b/hwpfilter/source/hpara.h
@@ -57,20 +57,7 @@ class HWPPara;
 
 struct LineInfo
 {
-/* the position of the starting character: the control has a different length 
*/
-/**
- * Starting character position
- */
-unsigned shortpos;
-hunit space_width;
-hunit height;
 hunit pgy;/* internal */
-hunit sx; /* internal */
-hunit psx;/* internal */
-hunit pex;/* internal */
-// for formatting
-hunit height_sp;
-unsigned shortsoftbreak;  // column, page, section
 
 void  Read(HWPFile , HWPPara const *para);
 };


[Libreoffice-commits] core.git: hwpfilter/source

2022-07-17 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpread.cxx |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 793267e2b7f41c4ce24615491ac2153040a8a148
Author: Caolán McNamara 
AuthorDate: Sat Jul 16 17:35:55 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sun Jul 17 12:22:22 2022 +0200

ofz: Use-of-uninitialized-value

Change-Id: I4afb1f9893eadda28d4d9d2e90d5d6293a8ee60c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137128
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 6477b193b204..a77f380b5055 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -91,10 +91,12 @@ bool FieldCode::Read(HWPFile & hwpf)
 str2.reset( new hchar[len2_ ? len2_ : 1] );
 str3.reset( new hchar[len3_ ? len3_ : 1] );
 
-hwpf.Read2b(str1.get(), len1_);
+if (hwpf.Read2b(str1.get(), len1_) != len1_)
+return false;
 hwpf.SkipBlock(len1 - (len1_ * sizeof(hchar)));
 str1[len1_ ? (len1_ - 1) : 0] = 0;
-hwpf.Read2b(str2.get(), len2_);
+if (hwpf.Read2b(str2.get(), len2_) != len2_)
+return false;
 hwpf.SkipBlock(len2 - (len2_ * sizeof(hchar)));
 str2[len2_ ? (len2_ - 1) : 0] = 0;
 if (hwpf.Read2b(str3.get(), len3_) != len3_)


[Libreoffice-commits] core.git: hwpfilter/source

2022-06-21 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit 8fb6f3d894093c729e8ee304f8b6fb553a7ceac4
Author: Caolán McNamara 
AuthorDate: Tue Jun 21 08:57:03 2022 +0100
Commit: Caolán McNamara 
CommitDate: Tue Jun 21 12:20:19 2022 +0200

ofz#48161 Container-overflow

Change-Id: I99a63c3cfa48344221dbe4a7400d313d875abd82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136207
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index f5592124b37d..ab495315722c 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -2816,10 +2816,8 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 }
 
 int n = 0;
-while (n < para->nch)
+for (const auto& box : para->hhstr)
 {
-const auto& box = para->hhstr[n];
-
 if (!box->hh)
 break;
 


[Libreoffice-commits] core.git: hwpfilter/source

2022-06-20 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hpara.cxx |8 +++
 hwpfilter/source/hpara.h   |2 -
 hwpfilter/source/hwpreader.cxx |   44 +
 3 files changed, 28 insertions(+), 26 deletions(-)

New commits:
commit b4760a4feefc8696dc29fdd7320b65d2d3b7e523
Author: Caolán McNamara 
AuthorDate: Mon Jun 20 11:41:39 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon Jun 20 16:26:58 2022 +0200

ofz#47118 Timeout

Change-Id: I544074822cfa51ae162afa370c488a1f6132088c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136145
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hpara.cxx b/hwpfilter/source/hpara.cxx
index 9ac169ab4382..52e13b829744 100644
--- a/hwpfilter/source/hpara.cxx
+++ b/hwpfilter/source/hpara.cxx
@@ -166,12 +166,12 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag)
 auto hBox = readHBox(hwpf);
 if (!hBox)
 return false;
-hhstr[ii] = std::move(hBox);
-if (hhstr[ii]->hh == CH_END_PARA)
+hhstr.emplace_back(std::move(hBox));
+if (hhstr.back()->hh == CH_END_PARA)
 break;
-if( hhstr[ii]->hh < CH_END_PARA )
+if( hhstr.back()->hh < CH_END_PARA )
 pshape->reserved[0] = 0;
-ii += hhstr[ii]->WSize();
+ii += hhstr.back()->WSize();
 }
 return nch && !hwpf.State();
 }
diff --git a/hwpfilter/source/hpara.h b/hwpfilter/source/hpara.h
index 58694899ea38..fcf1681715b7 100644
--- a/hwpfilter/source/hpara.h
+++ b/hwpfilter/source/hpara.h
@@ -114,7 +114,7 @@ class DLLEXPORT HWPPara
 /**
  * Box object list
  */
-std::map> hhstr;
+std::vector> hhstr;
 
 HWPPara(void);
 ~HWPPara(void);
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 05079365b3b3..f5592124b37d 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -2636,11 +2636,8 @@ void HwpReader::make_text_p0(HWPPara * para, bool 
bParaStart)
 startEl("text:span");
 mxList->clear();
 
-int n = 0;
-while (n < para->nch)
+for (const auto& box : para->hhstr)
 {
-const auto& box = para->hhstr[n];
-
 if (!box->hh)
 break;
 
@@ -2669,7 +2666,6 @@ void HwpReader::make_text_p0(HWPPara * para, bool 
bParaStart)
 str.push_back(dest[j]);
 }
 }
-n += box->WSize();
 }
 }
 
@@ -2680,7 +2676,6 @@ void HwpReader::make_text_p0(HWPPara * para, bool 
bParaStart)
 void HwpReader::make_text_p1(HWPPara * para,bool bParaStart)
 {
 hchar_string str;
-int n;
 int res;
 hchar dest[3];
 int curr = para->cshape->index;
@@ -2712,9 +2707,12 @@ void HwpReader::make_text_p1(HWPPara * para,bool 
bParaStart)
 startEl("text:span");
 mxList->clear();
 
-for (n = 0; n < para->nch && para->hhstr[n]->hh;
-n += para->hhstr[n]->WSize())
+int n = 0;
+for (const auto& box : para->hhstr)
 {
+if (!box->hh)
+break;
+
 if (para->GetCharShape(n)->index != curr)
 {
 makeChars(str);
@@ -2725,13 +2723,13 @@ void HwpReader::make_text_p1(HWPPara * para,bool 
bParaStart)
 startEl("text:span");
 mxList->clear();
 }
-if (para->hhstr[n]->hh == CH_SPACE && !firstspace)
+if (box->hh == CH_SPACE && !firstspace)
 {
 makeChars(str);
 startEl("text:s");
 endEl("text:s");
 }
-else if (para->hhstr[n]->hh == CH_END_PARA)
+else if (box->hh == CH_END_PARA)
 {
 makeChars(str);
 endEl("text:span");
@@ -2740,18 +2738,19 @@ void HwpReader::make_text_p1(HWPPara * para,bool 
bParaStart)
 }
 else
 {
-if( para->hhstr[n]->hh < CH_SPACE )
+if( box->hh < CH_SPACE )
   continue;
-if (para->hhstr[n]->hh == CH_SPACE)
+if (box->hh == CH_SPACE)
 firstspace = 0;
 else
 firstspace = 1;
-res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
+res = hcharconv(box->hh, dest, UNICODE);
 for( int j = 0 ; j < res; j++ )
 {
 str.push_back(dest[j]);
 }
 }
+n += box->WSize();
 }
 }
 
@@ -3581,21 +3580,22 @@ void HwpReader::makeFormula(TxtBox * hbox)
 char mybuf[3000];
 HWPPara* pPar;
 
-int n, c, res;
 hchar dest[3];
 size_t l = 0;
 
 pPar = hbox->plists[0].empty() ? nullptr : hbox->plists[0].front().get();
 while( pPar )
 {
-for( n = 0; n < pPar->nch && pPar->hhstr.count(n) && 
pPar->hhstr[n]->hh;
-n += pPar->hhstr[n]->WSize() )
+for (const auto& box : pPar->hhstr)
 {
+if (!box->hh)
+break;
+
 if (l >= sizeof(mybuf)-7)
 break;
-res = 

[Libreoffice-commits] core.git: hwpfilter/source

2022-06-20 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hinfo.cxx |   19 +--
 hwpfilter/source/hinfo.h   |6 +++---
 hwpfilter/source/hwpfile.cxx   |   12 ++--
 hwpfilter/source/hwpreader.cxx |6 +++---
 4 files changed, 25 insertions(+), 18 deletions(-)

New commits:
commit 43ae4e9a694c68101a907b0d1e31b4bd57e11bd1
Author: Caolán McNamara 
AuthorDate: Mon Jun 20 10:29:00 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon Jun 20 13:13:17 2022 +0200

ofz#47463 OOM only first byte of 'font', 'ratio' and 'space' are used

1.098GB -> 854.6MB

Change-Id: I3390c3a5abe457f8d0ad49b03b50a2d353566c2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136142
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hinfo.cxx b/hwpfilter/source/hinfo.cxx
index 505936b92aae..9a4eb628b015 100644
--- a/hwpfilter/source/hinfo.cxx
+++ b/hwpfilter/source/hinfo.cxx
@@ -261,10 +261,10 @@ void ParaShape::Read(HWPFile & hwpf)
 CharShape::CharShape()
 : index(0)
 , size(0)
-, font{0}
-, ratio{0}
-, space{0}
 , color{0}
+, font(0)
+, space(0)
+, ratio(0)
 , shade(0)
 , attr(0)
 {
@@ -276,9 +276,16 @@ void CharShape::Read(HWPFile & hwpf)
 if (!hwpf.Read2b(tmp16))
 return;
 size = tmp16;
-hwpf.ReadBlock(font, NLanguage);
-hwpf.ReadBlock(ratio, NLanguage);
-hwpf.ReadBlock(space, NLanguage);
+
+hwpf.Read1b(font);
+hwpf.SkipBlock(NLanguage - 1); //skip unused part of remaining font field
+
+hwpf.Read1b(ratio);
+hwpf.SkipBlock(NLanguage - 1); //skip unused part of remaining ratio field
+
+hwpf.Read1b(space);
+hwpf.SkipBlock(NLanguage - 1); //skip unused part of remaining space field
+
 hwpf.ReadBlock(color, 2);
 hwpf.Read1b(shade);
 hwpf.Read1b(attr);
diff --git a/hwpfilter/source/hinfo.h b/hwpfilter/source/hinfo.h
index 003dafc0d308..fe473f4effc4 100644
--- a/hwpfilter/source/hinfo.h
+++ b/hwpfilter/source/hinfo.h
@@ -219,10 +219,10 @@ struct CharShape
  * Font size
  */
 hunit size;
-unsigned char font[NLanguage];
-unsigned char ratio[NLanguage];
-signed char   space[NLanguage];   /* 자간 */
 unsigned char color[2];
+unsigned char font;
+char space;   /* 자간 */
+unsigned char ratio;
 unsigned char shade;
 unsigned char attr;
 
diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index 58d6c4849d91..f9d5b3ab6008 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -603,9 +603,9 @@ int HWPFile::compareCharShape(CharShape const *shape)
 CharShape *cshape = getCharShape(i);
 
 if( shape->size == cshape->size &&
-shape->font[0] == cshape->font[0] &&
-shape->ratio[0] == cshape->ratio[0] &&
-shape->space[0] == cshape->space[0] &&
+shape->font == cshape->font &&
+shape->ratio == cshape->ratio &&
+shape->space == cshape->space &&
 shape->color[1] == cshape->color[1] &&
 shape->color[0] == cshape->color[0] &&
 shape->shade == cshape->shade &&
@@ -639,9 +639,9 @@ int HWPFile::compareParaShape(const ParaShape* shape)
 shape->pagebreak == pshape->pagebreak)
 {
 if (shape->cshape->size == pshape->cshape->size &&
-shape->cshape->font[0] == pshape->cshape->font[0] &&
-shape->cshape->ratio[0] == pshape->cshape->ratio[0] &&
-shape->cshape->space[0] == pshape->cshape->space[0] &&
+shape->cshape->font == pshape->cshape->font &&
+shape->cshape->ratio == pshape->cshape->ratio &&
+shape->cshape->space == pshape->cshape->space &&
 shape->cshape->color[1] == pshape->cshape->color[1] &&
 shape->cshape->color[0] == pshape->cshape->color[0] &&
 shape->cshape->shade == pshape->cshape->shade &&
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 87c2e6412bd5..05079365b3b3 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -1271,7 +1271,7 @@ void HwpReader::parseCharShape(CharShape const * cshape)
 mxList->addAttribute("style:font-size-asian", sXML_CDATA, 
OUString::number(cshape->size / 25) + "pt");
 
 ::std::string const tmp = hstr2ksstr(kstr2hstr(
-reinterpret_cast(hwpfont.GetFontName(0, 
cshape->font[0]))).c_str());
+reinterpret_cast(hwpfont.GetFontName(0, 
cshape->font))).c_str());
 double fRatio = 1.0;
 int size = getRepFamilyName(tmp.c_str(), d->buf, fRatio);
 
@@ -1281,9 +1281,9 @@ void HwpReader::parseCharShape(CharShape const * cshape)
 OUString(d->buf, size, RTL_TEXTENCODING_EUC_KR));
 
 mxList->addAttribute("style:text-scale", sXML_CDATA,
-OUString::number(static_cast(cshape->ratio[0] * fRatio)) + "%");
+OUString::number(static_cast(cshape->ratio * fRatio)) 

[Libreoffice-commits] core.git: hwpfilter/source

2022-06-03 Thread Stephan Bergmann (via logerrit)
 hwpfilter/source/hbox.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 949f2e0624e798c4ee841585fb38e7d4b693e1d8
Author: Stephan Bergmann 
AuthorDate: Fri Jun 3 10:27:55 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Jun 3 13:26:37 2022 +0200

No need for a cast here when comparing against const int DATE_SIZE = 40

Change-Id: I2e9190ac08dc79fe624572ff3a96c32c18afce29
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135341
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index 59b0285926fb..ea8d46e5f59e 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -148,7 +148,7 @@ hchar_string DateCode::GetString()
 format[DATE_SIZE - 1] = 0;
 fmt = format[0] ? format : defaultform;
 
-for (; *fmt && (static_cast(ret.size()) < DATE_SIZE); fmt++)
+for (; *fmt && (ret.size() < DATE_SIZE); fmt++)
 {
 form = add_zero ? "%02d" : "%d";
 


[Libreoffice-commits] core.git: hwpfilter/source

2022-05-16 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hinfo.cxx |3 +--
 hwpfilter/source/hinfo.h   |1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

New commits:
commit dfd517af96c61b6bef75dde525f60bdd2a29a1a9
Author: Caolán McNamara 
AuthorDate: Sun May 15 17:59:45 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon May 16 09:57:23 2022 +0200

ofz#47473 OOM just skip the unused "reserved" data on read

and don't store it

Change-Id: I7e68111b5ed724c5eab9e8040b8c28f542064ae5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134353
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hinfo.cxx b/hwpfilter/source/hinfo.cxx
index f842f0d683ff..505936b92aae 100644
--- a/hwpfilter/source/hinfo.cxx
+++ b/hwpfilter/source/hinfo.cxx
@@ -267,7 +267,6 @@ CharShape::CharShape()
 , color{0}
 , shade(0)
 , attr(0)
-, reserved{0}
 {
 }
 
@@ -283,7 +282,7 @@ void CharShape::Read(HWPFile & hwpf)
 hwpf.ReadBlock(color, 2);
 hwpf.Read1b(shade);
 hwpf.Read1b(attr);
-hwpf.ReadBlock(reserved, 4);
+hwpf.SkipBlock(4);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hinfo.h b/hwpfilter/source/hinfo.h
index 57067646c856..003dafc0d308 100644
--- a/hwpfilter/source/hinfo.h
+++ b/hwpfilter/source/hinfo.h
@@ -225,7 +225,6 @@ struct CharShape
 unsigned char color[2];
 unsigned char shade;
 unsigned char attr;
-unsigned char reserved[4];
 
 void Read(HWPFile &);
 


[Libreoffice-commits] core.git: hwpfilter/source sw/source

2022-05-07 Thread Stephan Bergmann (via logerrit)
 hwpfilter/source/hstyle.cxx  |4 ++--
 sw/source/core/txtnode/modeltoviewhelper.cxx |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 7d1511cfd85915e7a0764eb9de4d7a4448741958
Author: Stephan Bergmann 
AuthorDate: Sat May 7 14:43:26 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Sat May 7 16:54:52 2022 +0200

GCC 12 is still just as broken

Change-Id: Ic2e151eb78512388150492b6dff0c39046d4d3c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133979
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/hwpfilter/source/hstyle.cxx b/hwpfilter/source/hstyle.cxx
index 39709f9ea97f..bf4538d686db 100644
--- a/hwpfilter/source/hstyle.cxx
+++ b/hwpfilter/source/hstyle.cxx
@@ -68,14 +68,14 @@ void HWPStyle::SetName(int n, char const* name)
 
 if (name)
 {
-#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 11) && !defined __clang__
+#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 12) && !defined __clang__
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wstringop-truncation"
 #endif
 auto const p = style[n].name;
 strncpy(p, name, MAXSTYLENAME);
 p[MAXSTYLENAME] = '\0'; // just in case, even though the array is 
zero-initialized
-#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 11) && !defined __clang__
+#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 12) && !defined __clang__
 #pragma GCC diagnostic pop
 #endif
 }
diff --git a/sw/source/core/txtnode/modeltoviewhelper.cxx 
b/sw/source/core/txtnode/modeltoviewhelper.cxx
index fa9b8f790860..c7b67a043b9e 100644
--- a/sw/source/core/txtnode/modeltoviewhelper.cxx
+++ b/sw/source/core/txtnode/modeltoviewhelper.cxx
@@ -179,14 +179,14 @@ ModelToViewHelper::ModelToViewHelper(const SwTextNode 
,
 [](auto const& it) { return it.second; }))
 {
 // prevent -Werror=maybe-uninitialized under gcc 11.2.0
-#if defined __GNUC__ && !defined __clang_ && __GNUC__ == 11
+#if defined __GNUC__ && !defined __clang_ && __GNUC__ >= 11 && __GNUC__ <= 12
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 #endif
 // i is still hidden but the Range end is oddly "-1"
 aHiddenMulti.Select({*oStartHidden, i}, true);
 oStartHidden.reset();
-#if defined __GNUC__ && !defined __clang_ && __GNUC__ == 11
+#if defined __GNUC__ && !defined __clang_ && __GNUC__ >= 11 && __GNUC__ <= 12
 #pragma GCC diagnostic pop
 #endif
 }


[Libreoffice-commits] core.git: hwpfilter/source

2022-05-02 Thread Stephan Bergmann (via logerrit)
 hwpfilter/source/hwpread.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2256912336fbcf0b985d84dfbf355d1728ee425c
Author: Stephan Bergmann 
AuthorDate: Wed Apr 13 17:55:25 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Mon May 2 20:01:01 2022 +0200

Pick a better variable type

Change-Id: I2a24201d0e9cb230aefbb92dadf30907b0d1dccb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133677
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index a1b9415f70b4..6477b193b204 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -106,7 +106,7 @@ bool FieldCode::Read(HWPFile & hwpf)
 
 if( type[0] == 3 && type[1] == 2 ){ /* It must create a format as created 
date. */
   DateCode *pDate = new DateCode;
-  for (int i = 0 ; i < static_cast(len3_); i++) {
+  for (uint i = 0 ; i < len3_; i++) {
 if(str3[i] == 0 ) break;
 if( i >= DATE_SIZE ) break;
 pDate->format[i] = str3[i];


[Libreoffice-commits] core.git: hwpfilter/source

2022-05-01 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |   19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

New commits:
commit b4dbdbdc9755dbbb586039eb48b935e7dbcc4cbb
Author: Caolán McNamara 
AuthorDate: Sat Apr 30 20:40:44 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sun May 1 11:02:02 2022 +0200

ofz#47118 Timeout

Change-Id: I5cf7f07c00faebb8005b150c9638dfbb742d156f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133666
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 6781267fdd7f..87c2e6412bd5 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -2608,7 +2608,6 @@ void HwpReader::makeChars(hchar_string & rStr)
 void HwpReader::make_text_p0(HWPPara * para, bool bParaStart)
 {
 hchar_string str;
-int n;
 int res;
 hchar dest[3];
 unsigned char firstspace = 0;
@@ -2637,16 +2636,21 @@ void HwpReader::make_text_p0(HWPPara * para, bool 
bParaStart)
 startEl("text:span");
 mxList->clear();
 
-for (n = 0; n < para->nch && para->hhstr[n]->hh;
-n += para->hhstr[n]->WSize())
+int n = 0;
+while (n < para->nch)
 {
-if (para->hhstr[n]->hh == CH_SPACE && !firstspace)
+const auto& box = para->hhstr[n];
+
+if (!box->hh)
+break;
+
+if (box->hh == CH_SPACE && !firstspace)
 {
 makeChars(str);
 startEl("text:s");
 endEl("text:s");
 }
-else if (para->hhstr[n]->hh == CH_END_PARA)
+else if (box->hh == CH_END_PARA)
 {
 makeChars(str);
 endEl("text:span");
@@ -2655,16 +2659,17 @@ void HwpReader::make_text_p0(HWPPara * para, bool 
bParaStart)
 }
 else
 {
-if (para->hhstr[n]->hh == CH_SPACE)
+if (box->hh == CH_SPACE)
 firstspace = 0;
 else
 firstspace = 1;
-res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
+res = hcharconv(box->hh, dest, UNICODE);
 for( int j = 0 ; j < res; j++ )
 {
 str.push_back(dest[j]);
 }
 }
+n += box->WSize();
 }
 }
 


[Libreoffice-commits] core.git: hwpfilter/source

2022-04-27 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |   67 -
 1 file changed, 33 insertions(+), 34 deletions(-)

New commits:
commit 53392cbcba0c18fa56a9d7d65fa885fcf52ac17b
Author: Caolán McNamara 
AuthorDate: Tue Apr 26 19:41:04 2022 +0100
Commit: Caolán McNamara 
CommitDate: Wed Apr 27 09:44:55 2022 +0200

remove static buffer

Change-Id: I77ebc45000e09d1553c8e63402f30e720852c057
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133458
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 8b5803c09f56..6781267fdd7f 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -46,8 +46,6 @@
 // xmloff/xmlkyd.hxx
 constexpr OUStringLiteral sXML_CDATA = u"CDATA";
 
-static char buf[1024];
-
 namespace
 {
 double WTI(double x) { return x / 1800.; } // unit => inch
@@ -77,6 +75,7 @@ struct HwpReaderPrivate
 ShowPageNum *pPn;
 hchar *pField;
 int nPnPos;
+char buf[1024];
 };
 
 HwpReader::HwpReader() : mxList(new AttributeListImpl), d(new HwpReaderPrivate)
@@ -314,10 +313,10 @@ void HwpReader::makeMeta()
 else {
 minute = 0;
 }
-sprintf(buf,"%d-%02d-%02dT%02d:%02d:00",year,month,day,hour,minute);
+sprintf(d->buf,"%d-%02d-%02dT%02d:%02d:00",year,month,day,hour,minute);
 
 startEl("meta:creation-date");
-chars( OUString::createFromAscii(buf));
+chars( OUString::createFromAscii(d->buf));
 endEl("meta:creation-date");
 }
 
@@ -1274,12 +1273,12 @@ void HwpReader::parseCharShape(CharShape const * cshape)
 ::std::string const tmp = hstr2ksstr(kstr2hstr(
 reinterpret_cast(hwpfont.GetFontName(0, 
cshape->font[0]))).c_str());
 double fRatio = 1.0;
-int size = getRepFamilyName(tmp.c_str(), buf, fRatio);
+int size = getRepFamilyName(tmp.c_str(), d->buf, fRatio);
 
 mxList->addAttribute("fo:font-family", sXML_CDATA,
-OUString(buf, size, RTL_TEXTENCODING_EUC_KR));
+OUString(d->buf, size, RTL_TEXTENCODING_EUC_KR));
 mxList->addAttribute("style:font-family-asian", sXML_CDATA,
-OUString(buf, size, RTL_TEXTENCODING_EUC_KR));
+OUString(d->buf, size, RTL_TEXTENCODING_EUC_KR));
 
 mxList->addAttribute("style:text-scale", sXML_CDATA,
 OUString::number(static_cast(cshape->ratio[0] * fRatio)) + "%");
@@ -1814,8 +1813,8 @@ void HwpReader::makeTableStyle(Table *tbl)
 // column
 for (size_t i = 0 ; i < tbl->columns.nCount -1 ; i++)
 {
-sprintf(buf,"Table%d.%c",hbox->style.boxnum, static_cast('A'+i));
-mxList->addAttribute("style:name", sXML_CDATA, 
OUString::createFromAscii( buf ));
+sprintf(d->buf,"Table%d.%c",hbox->style.boxnum, 
static_cast('A'+i));
+mxList->addAttribute("style:name", sXML_CDATA, 
OUString::createFromAscii(d->buf));
 mxList->addAttribute("style:family", sXML_CDATA,"table-column");
 startEl("style:style");
 mxList->clear();
@@ -1830,8 +1829,8 @@ void HwpReader::makeTableStyle(Table *tbl)
 // row
 for (size_t i = 0 ; i < tbl->rows.nCount -1 ; i++)
 {
-sprintf(buf,"Table%d.row%" SAL_PRI_SIZET "u",hbox->style.boxnum, i + 
1);
-mxList->addAttribute("style:name", sXML_CDATA, 
OUString::createFromAscii( buf ));
+sprintf(d->buf,"Table%d.row%" SAL_PRI_SIZET "u",hbox->style.boxnum, i 
+ 1);
+mxList->addAttribute("style:name", sXML_CDATA, 
OUString::createFromAscii(d->buf));
 mxList->addAttribute("style:family", sXML_CDATA,"table-row");
 startEl("style:style");
 mxList->clear();
@@ -1846,8 +1845,8 @@ void HwpReader::makeTableStyle(Table *tbl)
 // cell
 for (auto const& tcell : tbl->cells)
 {
-sprintf(buf,"Table%d.%c%d",hbox->style.boxnum, 'A'+ 
tcell->nColumnIndex, tcell->nRowIndex +1);
-mxList->addAttribute("style:name", sXML_CDATA, 
OUString::createFromAscii( buf ));
+sprintf(d->buf,"Table%d.%c%d",hbox->style.boxnum, 'A'+ 
tcell->nColumnIndex, tcell->nRowIndex +1);
+mxList->addAttribute("style:name", sXML_CDATA, 
OUString::createFromAscii(d->buf));
 mxList->addAttribute("style:family", sXML_CDATA,"table-cell");
 startEl("style:style");
 mxList->clear();
@@ -3376,8 +3375,8 @@ void HwpReader::makeTable(TxtBox * hbox)
 // column
 for (size_t i = 0 ; i < tbl->columns.nCount -1 ; i++)
 {
-sprintf(buf,"Table%d.%c",hbox->style.boxnum, static_cast('A'+i));
-mxList->addAttribute("table:style-name", sXML_CDATA, 
OUString::createFromAscii( buf ));
+sprintf(d->buf,"Table%d.%c",hbox->style.boxnum, 
static_cast('A'+i));
+mxList->addAttribute("table:style-name", sXML_CDATA, 
OUString::createFromAscii(d->buf));
 startEl("table:table-column");
 mxList->clear();
 endEl("table:table-column");
@@ -3395,15 +3394,15 @@ void HwpReader::makeTable(TxtBox * hbox)
 

[Libreoffice-commits] core.git: hwpfilter/source

2022-04-26 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 6a1a68596a822811db80c3f9d1bf1c30db75c972
Author: Caolán McNamara 
AuthorDate: Tue Apr 26 16:51:01 2022 +0100
Commit: Caolán McNamara 
CommitDate: Tue Apr 26 20:34:05 2022 +0200

ofz#47042 previous use of static variable affecting later runs

Change-Id: I64fb184e43fb025798781c85c9a0a8e0354b21b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133452
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index a6df282ede5b..8b5803c09f56 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -46,7 +46,6 @@
 // xmloff/xmlkyd.hxx
 constexpr OUStringLiteral sXML_CDATA = u"CDATA";
 
-static hchar *field = nullptr;
 static char buf[1024];
 
 namespace
@@ -70,12 +69,13 @@ struct HwpReaderPrivate
 bInHeader = false;
 nPnPos = 0;
 pPn = nullptr;
-
+pField = nullptr;
 }
 bool bFirstPara;
 bool bInBody;
 bool bInHeader;
 ShowPageNum *pPn;
+hchar *pField;
 int nPnPos;
 };
 
@@ -2873,7 +2873,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 firstspace = 1;
 if( hbox->type[0] == 4 && hbox->type[1] == 0 )
 {
- field = hbox->str3.get();
+ d->pField = hbox->str3.get();
 }
 else{
  makeFieldCode(str, hbox);
@@ -2886,7 +2886,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 if( hbox->type[0] == 4 && hbox->type[1] == 0 )
 {
  makeFieldCode(str, hbox);
- field = nullptr;
+ d->pField = nullptr;
 }
 infield = false;
 str.clear();
@@ -3055,8 +3055,8 @@ void HwpReader::makeFieldCode(hchar_string const & rStr, 
FieldCode const *hbox)
 if( hbox->type[0] == 4 && hbox->type[1] == 0 )
 {
 mxList->addAttribute("text:placeholder-type", sXML_CDATA, "text");
-if( field )
-  mxList->addAttribute("text:description", sXML_CDATA, 
hstr2OUString(field));
+if (d->pField)
+mxList->addAttribute("text:description", sXML_CDATA, 
hstr2OUString(d->pField));
 startEl("text:placeholder");
 mxList->clear();
 chars( fromHcharStringToOUString(rStr) );


[Libreoffice-commits] core.git: hwpfilter/source include/sal

2022-04-25 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |8 
 include/sal/log-areas.dox  |1 +
 2 files changed, 9 insertions(+)

New commits:
commit 0609ee7ec0748b85bcc2b741c73b5f2cbb2f35d1
Author: Caolán McNamara 
AuthorDate: Mon Apr 25 11:32:44 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon Apr 25 17:25:33 2022 +0200

ofz#46794 Timeout

Change-Id: I58bfdbe4bab0ee8b7ff49f937711dff649392bbc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133373
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 3560d6d4b334..a6df282ede5b 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "fontmap.hxx"
 #include "formula.h"
@@ -40,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 // xmloff/xmlkyd.hxx
 constexpr OUStringLiteral sXML_CDATA = u"CDATA";
@@ -955,6 +957,12 @@ void HwpReader::makeMasterStyles()
 PageSetting *pPrevSet = nullptr;
 PageSetting *pPage = nullptr;
 
+if (nMax > SAL_MAX_UINT16 && utl::ConfigManager::IsFuzzing())
+{
+SAL_WARN("filter.hwp", "too many pages: " << nMax << " clip to " << 
SAL_MAX_UINT16);
+nMax = SAL_MAX_UINT16;
+}
+
 for( i = 1; i <= nMax ; i++ )
 {
 if( i == 1 )
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index 4e9c3105c844..f6b67006b255 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -227,6 +227,7 @@ certain functionality.
 
 @li @c filter.config
 @li @c filter.eps
+@li @c filter.hwp - Hangul word processor import
 @li @c filter.icgm
 @li @c filter.ms - escher import/export
 @li @c filter.odfflatxml


[Libreoffice-commits] core.git: hwpfilter/source

2022-04-25 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8ad7603c7c6ba327ff1e836e023c2ad0ab529d53
Author: Caolán McNamara 
AuthorDate: Mon Apr 25 11:09:11 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon Apr 25 14:15:12 2022 +0200

vector is a little faster than deque here

Change-Id: I0471143b13ea8113919ed71abe956f27729cecad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133372
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 56e54d5920c0..3560d6d4b334 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -880,7 +880,7 @@ void HwpReader::makeMasterStyles()
 
 int i;
 int nMax = hwpfile.getMaxSettedPage();
-std::deque aSet(nMax + 1);
+std::vector aSet(nMax + 1);
 
 for( i = 0 ; i < hwpfile.getPageNumberCount() ; i++ )
 {


[Libreoffice-commits] core.git: hwpfilter/source

2022-04-14 Thread Stephan Bergmann (via logerrit)
 hwpfilter/source/fontmap.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit c36f9e981d583c5f62943db9cf4116cbda0f0501
Author: Stephan Bergmann 
AuthorDate: Wed Apr 13 17:53:58 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Apr 14 11:41:21 2022 +0200

Pick a better variable type

Change-Id: I1c9d3bcb1e750b130a04105ab9cf370b7f31f392
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132994
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/hwpfilter/source/fontmap.cxx b/hwpfilter/source/fontmap.cxx
index fcd6c4822169..7eba07c03ad3 100644
--- a/hwpfilter/source/fontmap.cxx
+++ b/hwpfilter/source/fontmap.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include 
 #include 
 #ifdef __sun
 #include 
@@ -151,7 +152,7 @@ const char* const RepFontTab[] =
 
 int getRepFamilyName(const char* orig, char *buf, double )
 {
-for( int i = 0 ; i < int(SAL_N_ELEMENTS(FontMapTab)); i++)
+for( std::size_t i = 0 ; i < SAL_N_ELEMENTS(FontMapTab); i++)
 {
 if( !strcmp(orig, FontMapTab[i].familyname) ){
 ratio = FontMapTab[i].ratio;


[Libreoffice-commits] core.git: hwpfilter/source

2022-04-07 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |   46 +++--
 1 file changed, 26 insertions(+), 20 deletions(-)

New commits:
commit c44a9e6efe99d4dd8d553be5de96e970c6c3c9e4
Author: Caolán McNamara 
AuthorDate: Thu Apr 7 20:23:10 2022 +0100
Commit: Caolán McNamara 
CommitDate: Thu Apr 7 23:58:59 2022 +0200

ofz#46467 Timeout

Change-Id: Ib2a248a6f912a340d2f0b79a068b68036fa357c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132690
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 7ab6689f8df3..56e54d5920c0 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -2750,7 +2750,7 @@ void HwpReader::make_text_p1(HWPPara * para,bool 
bParaStart)
 void HwpReader::make_text_p3(HWPPara * para,bool bParaStart)
 {
 hchar_string str;
-int n, res;
+int res;
 hchar dest[3];
 unsigned char firstspace = 0;
 bool pstart = bParaStart;
@@ -2804,10 +2804,15 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 d->bInHeader = false;
 }
 
-for (n = 0; n < para->nch && para->hhstr[n]->hh;
-n += para->hhstr[n]->WSize())
+int n = 0;
+while (n < para->nch)
 {
-if( para->hhstr[n]->hh == CH_END_PARA )
+const auto& box = para->hhstr[n];
+
+if (!box->hh)
+break;
+
+if (box->hh == CH_END_PARA)
 {
 if (!str.empty())
 {
@@ -2820,7 +2825,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 if( pstart ){ ENDP(); }
 break;
 }
-else if( para->hhstr[n]->hh == CH_SPACE  && !firstspace)
+else if (box->hh == CH_SPACE  && !firstspace)
 {
 if( !pstart ) {STARTP(); }
 if( !tstart ) {STARTT(n);}
@@ -2829,7 +2834,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 mxList->clear();
 endEl("text:s");
 }
-else if ( para->hhstr[n]->hh >= CH_SPACE )
+else if (box->hh >= CH_SPACE)
 {
 if( n > 0 )
 if( para->GetCharShape(n)->index != 
para->GetCharShape(n-1)->index && !infield )
@@ -2839,19 +2844,19 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
  makeChars(str);
  ENDT();
 }
-if( para->hhstr[n]->hh == CH_SPACE )
+if (box->hh == CH_SPACE)
 firstspace = 0;
 else
 firstspace = 1;
-res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
+res = hcharconv(box->hh, dest, UNICODE);
 for( int j = 0 ; j < res; j++ )
 {
 str.push_back(dest[j]);
 }
 }
-else if (para->hhstr[n]->hh == CH_FIELD)
+else if (box->hh == CH_FIELD)
 {
-FieldCode *hbox = static_cast(para->hhstr[n].get());
+FieldCode *hbox = static_cast(box.get());
 if( hbox->location_info == 1)
 {
 if( !pstart ) {STARTP(); }
@@ -2881,13 +2886,13 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 }
 else
 {
-switch (para->hhstr[n]->hh)
+switch (box->hh)
 {
 case CH_BOOKMARK:
 if( !pstart ) {STARTP(); }
 if( !tstart ) {STARTT(n);}
 makeChars(str);
-makeBookmark(static_cast(para->hhstr[n].get()));
+makeBookmark(static_cast(box.get()));
 break;
 case CH_DATE_FORM:// 7
 break;
@@ -2895,7 +2900,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 if( !pstart ) {STARTP(); }
 if( !tstart ) {STARTT(n);}
 makeChars(str);
-makeDateCode(static_cast(para->hhstr[n].get()));
+makeDateCode(static_cast(box.get()));
 break;
 case CH_TAB:  // 9
 if( !pstart ) {STARTP(); }
@@ -2909,7 +2914,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 case CH_TEXT_BOX: /* 10 - ordered by 
Table/text box/formula/button/hypertext */
 {
 /* produce tables first, and treat formula as being in 
text:p. */
-TxtBox *hbox = static_cast(para->hhstr[n].get());
+TxtBox *hbox = static_cast(box.get());
 
 if( hbox->style.anchor_type == 0 )
 {
@@ -2943,7 +2948,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 }
 case CH_PICTURE:  // 11
 {
-   

[Libreoffice-commits] core.git: hwpfilter/source

2022-04-04 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 6905434f40a1b3a58955b3b444d69f239be1b14e
Author: Caolán McNamara 
AuthorDate: Mon Apr 4 09:08:52 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon Apr 4 11:43:57 2022 +0200

ofz#46331 Null-dereference READ

Change-Id: Id03c7fc437d67e01d6a1ec0547b2584396066201
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132497
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 8c84970867ba..7ab6689f8df3 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -4442,7 +4442,7 @@ void HwpReader::makeHidden(Hidden * hbox)
 
 while (para)
 {
-for (int n = 0; n < para->nch && para->hhstr[n]->hh;
+for (int n = 0; n < para->nch && para->hhstr.count(n) && 
para->hhstr[n]->hh;
 n += para->hhstr[n]->WSize())
 {
   res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-24 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hbox.cxx |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit e8c95b796626cb9db163f5d563fa67f38a5e92b0
Author: Caolán McNamara 
AuthorDate: Thu Mar 24 20:14:41 2022 +
Commit: Caolán McNamara 
CommitDate: Fri Mar 25 00:10:45 2022 +0100

ofz: ensure unsigned index

Change-Id: I38d6238a6eede0188f942229b2fb931614e56309
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132090
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index ed477155f7b9..59b0285926fb 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -175,7 +175,7 @@ hchar_string DateCode::GetString()
 case '@':
 {
 static_assert((std::size(eng_mon) - 1) / 3 == 12);
-size_t nIndex = (date[MONTH] - 1) % 12;
+size_t nIndex = o3tl::make_unsigned(date[MONTH] - 1) % 12;
 memcpy(cbuf, eng_mon + nIndex * 3, 3);
 cbuf[3] = '.';
 cbuf[4] = 0;
@@ -183,7 +183,7 @@ hchar_string DateCode::GetString()
 }
 case '*':
 {
-size_t nIndex = (date[MONTH] - 1) % std::size(en_mon);
+size_t nIndex = o3tl::make_unsigned(date[MONTH] - 1) % 
std::size(en_mon);
 strncat(cbuf, en_mon[nIndex], sizeof(cbuf) - strlen(cbuf) - 1);
 break;
 }
@@ -220,14 +220,14 @@ hchar_string DateCode::GetString()
 break;
 case '6':
 {
-size_t nIndex = date[WEEK] % std::size(kor_week);
+size_t nIndex = o3tl::make_unsigned(date[WEEK]) % 
std::size(kor_week);
 ret.push_back(kor_week[nIndex]);
 break;
 }
 case '^':
 {
 static_assert((std::size(eng_week) - 1) / 3 == 7);
-size_t nIndex = date[WEEK] % 7;
+size_t nIndex = o3tl::make_unsigned(date[WEEK]) % 7;
 memcpy(cbuf, eng_week + nIndex * 3, 3);
 cbuf[3] = '.';
 cbuf[4] = 0;
@@ -235,7 +235,7 @@ hchar_string DateCode::GetString()
 }
 case '_':
 {
-size_t nIndex = date[WEEK] % std::size(en_week);
+size_t nIndex = o3tl::make_unsigned(date[WEEK]) % 
std::size(en_week);
 strncat(cbuf, en_week[nIndex], sizeof(cbuf) - strlen(cbuf) - 1);
 break;
 }
@@ -274,7 +274,7 @@ hchar_string DateCode::GetString()
 fmt++;
 if (*fmt == '6')
 {
-size_t nIndex = date[WEEK] % std::size(china_week);
+size_t nIndex = o3tl::make_unsigned(date[WEEK]) % 
std::size(china_week);
 ret.push_back(china_week[nIndex]);
 break;
 }


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-21 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/formula.cxx |   32 ++--
 hwpfilter/source/grammar.cxx |   66 +--
 hwpfilter/source/nodes.h |7 +---
 3 files changed, 51 insertions(+), 54 deletions(-)

New commits:
commit 22fa995ae81739aa1b7fcc5ffb277d1a46bda452
Author: Caolán McNamara 
AuthorDate: Mon Mar 21 09:13:02 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Mar 21 13:25:27 2022 +0100

ofz#45816 Direct-leak

Change-Id: I73ed541c9a8fb6d9b0a8ee86ce7cf581721a9b73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131889
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/formula.cxx b/hwpfilter/source/formula.cxx
index f9ab458f..6093681b2de5 100644
--- a/hwpfilter/source/formula.cxx
+++ b/hwpfilter/source/formula.cxx
@@ -191,11 +191,11 @@ void Formula::makeIdentifier(Node *res)
  case ID_CHARACTER :
 #ifdef DEBUG
   inds;
-  fprintf(stderr,"%s\n",tmp->value);
+  fprintf(stderr,"%s\n",tmp->value.get());
   indo;
 #else
   rstartEl("math:mi", mxList);
-  rchars(OUString::createFromAscii(tmp->value));
+  rchars(OUString::createFromAscii(tmp->value.get()));
   rendEl("math:mi");
 #endif
   break;
@@ -204,7 +204,7 @@ void Formula::makeIdentifier(Node *res)
 #ifdef DEBUG
 #else
 rstartEl("math:mi", mxList);
-reucstr(tmp->value, strlen(tmp->value));
+reucstr(tmp->value.get(), strlen(tmp->value.get()));
 rendEl("math:mi");
 #endif
   }
@@ -213,22 +213,22 @@ void Formula::makeIdentifier(Node *res)
 #ifdef DEBUG
   inds;
   fprintf(stderr,"%s\n",
-  getMathMLEntity(tmp->value).c_str());
+  getMathMLEntity(tmp->value.get()).c_str());
   indo;
 #else
   rstartEl("math:mi", mxList);
-  runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value)));
+  
runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value.get(;
   rendEl("math:mi");
 #endif
   break;
  case ID_NUMBER :
 #ifdef DEBUG
   inds;
-  fprintf(stderr,"%s\n",tmp->value);
+  fprintf(stderr,"%s\n",tmp->value.get());
   indo;
 #else
   rstartEl("math:mn", mxList);
-  rchars(OUString::createFromAscii(tmp->value));
+  rchars(OUString::createFromAscii(tmp->value.get()));
   rendEl("math:mn");
 #endif
   break;
@@ -236,10 +236,10 @@ void Formula::makeIdentifier(Node *res)
  case ID_DELIMITER :
 {
 #ifdef DEBUG
-  inds; fprintf(stderr,"%s\n",tmp->value); indo;
+  inds; fprintf(stderr,"%s\n",tmp->value.get()); 
indo;
 #else
   rstartEl("math:mo", mxList);
-  runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value)));
+  
runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value.get(;
   rendEl("math:mo");
 #endif
   break;
@@ -370,7 +370,7 @@ void Formula::makeDecoration(Node *res)
  int isover = 1;
  Node *tmp = res->child;
  if( !tmp ) return;
- if( !strncmp(tmp->value,"under", 5) )
+ if( !strncmp(tmp->value.get(),"under", 5) )
   isover = 0;
 #ifdef DEBUG
  inds;
@@ -396,11 +396,11 @@ void Formula::makeDecoration(Node *res)
 #ifdef DEBUG
  inds;
  fprintf(stderr,"%s\n",
- getMathMLEntity(tmp->value).c_str());
+ getMathMLEntity(tmp->value.get()).c_str());
  indo;
 #else
  rstartEl("math:mo", mxList);
- runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value)));
+ runistr(fromHcharStringToOUString(getMathMLEntity(tmp->value.get(;
  rendEl("math:mo");
 #endif
 
@@ -518,13 +518,13 @@ void Formula::makeFence(Node *res)
 #ifdef DEBUG
  inds;
  fprintf(stderr,"\n",
-getMathMLEntity(tmp->value).c_str(),
-getMathMLEntity(tmp->next->next->value).c_str());
+getMathMLEntity(tmp->value.get()).c_str(),
+getMathMLEntity(tmp->next->next->value.get()).c_str());
 #else
  padd("open", "CDATA",
- OUString(reinterpret_cast(getMathMLEntity(tmp->value).c_str(;
+ OUString(reinterpret_cast(getMathMLEntity(tmp->value.get()).c_str(;
  padd("close", "CDATA",
- OUString(reinterpret_cast(getMathMLEntity(tmp->next->next->value).c_str(;
+ OUString(reinterpret_cast(getMathMLEntity(tmp->next->next->value.get()).c_str(;
  rstartEl("math:mfenced", mxList);
  mxList->clear();
 #endif
diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx
index 1545205472ee..199aab343208 100644
--- a/hwpfilter/source/grammar.cxx
+++ b/hwpfilter/source/grammar.cxx
@@ -514,55 +514,55 @@ yyreduce:
   switch (yyn) {
 
 case 1:
-{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = 
strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); 

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-21 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/grammar.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 095f5910e3781e5e0a3f9d09821d2be6be48abff
Author: Caolán McNamara 
AuthorDate: Mon Mar 21 09:52:39 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Mar 21 12:37:15 2022 +0100

ofz#45816 Direct-leak

Change-Id: I63f4828fb35a1f24c98ccd235af91d186b48058a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131897
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx
index 1fcdae8c37ec..1545205472ee 100644
--- a/hwpfilter/source/grammar.cxx
+++ b/hwpfilter/source/grammar.cxx
@@ -408,6 +408,12 @@ yynewstate:
   yyvs = static_cast(malloc (yystacksize * sizeof (*yyvsp)));
   memcpy (yyvs, yyvs1, size * sizeof (*yyvsp));
 
+  // https://lists.gnu.org/archive/html/bug-bison/2001-11/msg00021.html
+  if (yyss1 != yyssa)
+  free (yyss1);
+  if (yyvs1 != yyvsa)
+  free (yyvs1);
+
   yyssp = yyss + size - 1;
   yyvsp = yyvs + size - 1;
 


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-21 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/grammar.cxx |  161 ---
 1 file changed, 161 deletions(-)

New commits:
commit 5bd4d100acc08307c96e2b4cc7b8301210386fbd
Author: Caolán McNamara 
AuthorDate: Mon Mar 21 09:27:13 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Mar 21 12:36:58 2022 +0100

YYDEBUG is always 0

Change-Id: I9255b0c6447126e5b0907b12622b668bb4c79474
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131896
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx
index 740ec072b6fd..1fcdae8c37ec 100644
--- a/hwpfilter/source/grammar.cxx
+++ b/hwpfilter/source/grammar.cxx
@@ -21,9 +21,6 @@
 /*  A Bison parser, made from grammar.y
 by GNU Bison version 1.28  */
 
-#ifndef YYDEBUG
-#define YYDEBUG 0
-#endif
 #ifndef YYMAXDEPTH
 #define YYMAXDEPTH 0
 #endif
@@ -94,70 +91,6 @@ const char yytranslate[] = { 0,
 27,28,29,30,31
 };
 
-#if YYDEBUG != 0
-static const short yyprhs[] = { 0,
- 0, 2, 4, 6, 8,10,12,14,16,18,
-20,22,24,26,28,30,32,34,36,39,
-42,45,48,51,54,58,60,63,66,69,
-72,75,79,81,85,89,92,96,99,   103,
-   106,   110,   114,   120,   124,   130,   132,   135,   137,   140,
-   143,   147,   150,   154,   157,   159,   161,   165,   167,   169,
-   172,   174,   176,   178,   180,   182,   184,   186,   188,   190,
-   192,   194
-};
-
-static const short yyrhs[] = { 4,
- 0, 9, 0,10, 0, 5, 0,11, 0,12,
- 0,20, 0,21, 0, 7, 0, 6, 0,23,
- 0,17, 0,18, 0, 8, 0,32, 0,31,
- 0,22, 0,43, 0,44,43, 0,26,33,
- 0,26,34, 0,26,35, 0,26,36, 0,
-26,32, 0,26,32,32, 0,29, 0,27,
-37, 0,27,38, 0,27,39, 0,27,40,
- 0,27,32, 0,27,32,32, 0,30, 0,
-45,64,46, 0,33,64,37, 0,33,37,
- 0,35,64,39, 0,35,39, 0,34,64,
-38, 0,34,38, 0,65,41,65, 0,65,
-42,65, 0,65,41,49,42,49, 0,14,
-49,49, 0,35,64,16,64,39, 0, 3,
- 0,54,49, 0,19, 0,56,49, 0,13,
-49, 0,13,50,49, 0,24,49, 0,24,
-49,49, 0,25,49, 0,62, 0,63, 0,
-62,28,63, 0,64, 0,65, 0,64,65,
- 0,49, 0,48, 0,47, 0,51, 0,52,
- 0,53, 0,57, 0,58, 0,55, 0,44,
- 0,59, 0,60, 0
-};
-
-#endif
-
-#if YYDEBUG != 0
-static const short yyrline[] = { 0,
-59,61,62,63,64,65,66,67,68,69,
-70,71,72,73,74,75,76,79,81,84,
-86,87,88,89,90,91,94,96,97,98,
-99,   100,   101,   104,   108,   110,   113,   115,   118,   120,
-   123,   125,   126,   129,   133,   138,   142,   145,   149,   153,
-   155,   158,   160,   163,   168,   172,   174,   177,   181,   183,
-   186,   188,   189,   190,   191,   192,   193,   194,   195,   196,
-   197,   198
-};
-#endif
-
-
-#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
-
-static const char * const yytname[] = {   "$","error","$undefined.","ACCENT",
-"SMALL_GREEK","CAPITAL_GREEK","BINARY_OPERATOR","RELATION_OPERATOR","ARROW",
-"GENERAL_IDEN","GENERAL_OPER","BIG_SYMBOL","FUNCTION","ROOT","FRACTION","SUBSUP",
-"EQOVER","DELIMETER","LARGE_DELIM","DECORATION","SPACE_SYMBOL","CHARACTER","STRING",
-"OPERATOR","EQBEGIN","EQEND","EQLEFT","EQRIGHT","NEWLINE","LEFT_DELIM","RIGHT_DELIM",
-"DIGIT","'|'","'('","'['","'{'","'<'","')'","']'","'}'","'>'","'_'","'^'","Identifier",
-"PrimaryExpr","EQLeft","EQRight","Fence","Parenth","Block","Bracket","SubSupExpr",
-"FractionExpr","OverExpr","Accent","AccentExpr","Decoration","DecorationExpr",
-"RootExpr","BeginExpr","EndExpr","MathML","Lines","Line","ExprList","Expr", 
NULL
-};
-#endif
 
 const short yyr1[] = { 0,
 43,43,43,43,43,43,43,43,43,43,
@@ -373,12 +306,6 @@ YYSTYPE yylval; /*  the semantic value of the  
 */
 
 static int yynerrs; /*  number of parse errors so far   */
 
-#if YYDEBUG != 0
-int yydebug;/*  nonzero means print parse trace */
-/* Since this is uninitialized, it does not stop multiple parsers
-   from coexisting.  */
-#endif
-
 /*  YYINITDEPTH indicates the initial size of the parser's stacks   */
 
 #ifndef YYINITDEPTH
@@ -431,11 

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-21 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/grammar.cxx |   11 ---
 1 file changed, 11 deletions(-)

New commits:
commit 726a3712eec4e26e88492dd5005360938307209b
Author: Caolán McNamara 
AuthorDate: Mon Mar 21 09:25:32 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Mar 21 12:24:55 2022 +0100

yyoverflow is not defined

Change-Id: I5769b82ededd15a50892bc4e9478f69edb4722c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131893
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx
index 556bd2c8949f..740ec072b6fd 100644
--- a/hwpfilter/source/grammar.cxx
+++ b/hwpfilter/source/grammar.cxx
@@ -466,16 +466,6 @@ yynewstate:
   /* Get the current used size of the three stacks, in elements.  */
   int size = yyssp - yyss + 1;
 
-#ifdef yyoverflow
-  /* Each stack pointer address is followed by the size of
- the data in use in that stack, in bytes.  */
-  yyoverflow("parser stack overflow",
- , size * sizeof (*yyssp),
- , size * sizeof (*yyvsp),
- );
-
-  yyss = yyss1; yyvs = yyvs1;
-#else /* no yyoverflow */
   /* Extend the stack our own way.  */
   if (yystacksize >= YYMAXDEPTH)
 {
@@ -495,7 +485,6 @@ yynewstate:
   memcpy (yyss, yyss1, size * sizeof (*yyssp));
   yyvs = static_cast(malloc (yystacksize * sizeof (*yyvsp)));
   memcpy (yyvs, yyvs1, size * sizeof (*yyvsp));
-#endif /* no yyoverflow */
 
   yyssp = yyss + size - 1;
   yyvsp = yyvs + size - 1;


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-21 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/grammar.cxx |   88 ---
 1 file changed, 88 deletions(-)

New commits:
commit b77091684ba3de0a2009a1bc42514ef48ae6bcfc
Author: Caolán McNamara 
AuthorDate: Mon Mar 21 09:21:43 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Mar 21 12:22:46 2022 +0100

YYLSP_NEEDED is not defined

Change-Id: I324e811a84916f27037b2fe9df0aed2db5458564
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131890
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx
index fdcdbb139d75..c5a8997c0e28 100644
--- a/hwpfilter/source/grammar.cxx
+++ b/hwpfilter/source/grammar.cxx
@@ -368,19 +368,11 @@ const short yycheck[] = {11,
 #endif
 
 #ifdef YYPURE
-#ifdef YYLSP_NEEDED
-#ifdef YYLEX_PARAM
-#define YYLEX   yylex(, , YYLEX_PARAM)
-#else
-#define YYLEX   yylex(, )
-#endif
-#else /* not YYLSP_NEEDED */
 #ifdef YYLEX_PARAM
 #define YYLEX   yylex(, YYLEX_PARAM)
 #else
 #define YYLEX   yylex()
 #endif
-#endif /* not YYLSP_NEEDED */
 #endif
 
 /* If nonreentrant, generate the variables here */
@@ -391,11 +383,6 @@ static int yychar;  /*  the lookahead symbol*/
 YYSTYPE yylval; /*  the semantic value of the   */
 /*  lookahead symbol*/
 
-#ifdef YYLSP_NEEDED
-YYLTYPE yylloc; /*  location data for the lookahead */
-/*  symbol  */
-#endif
-
 static int yynerrs; /*  number of parse errors so far   */
 #endif  /* not YYPURE */
 
@@ -462,14 +449,6 @@ yyparse(YYPARSE_PARAM_ARG)
   short *yyss = yyssa;  /*  refer to the stacks through separate pointers 
*/
   YYSTYPE *yyvs = yyvsa;/*  to allow yyoverflow to reallocate them 
elsewhere */
 
-#ifdef YYLSP_NEEDED
-  YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack  */
-  YYLTYPE *yyls = yylsa;
-  YYLTYPE *yylsp;
-
-#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
-#endif
-
   int yystacksize = YYINITDEPTH;
   int yyfree_stacks = 0;
 
@@ -477,9 +456,6 @@ yyparse(YYPARSE_PARAM_ARG)
   int yychar;
   YYSTYPE yylval;
   int yynerrs;
-#ifdef YYLSP_NEEDED
-  YYLTYPE yylloc;
-#endif
 #endif
 
   YYSTYPE yyval;/*  the variable used to return */
@@ -506,9 +482,6 @@ yyparse(YYPARSE_PARAM_ARG)
 
   yyssp = yyss - 1;
   yyvsp = yyvs;
-#ifdef YYLSP_NEEDED
-  yylsp = yyls;
-#endif
 
 /* Push a new state, which is found in  yystate  .  */
 /* In all cases, when you get here, the value and location stacks
@@ -523,9 +496,6 @@ yynewstate:
   /* Use copies of these so that the &'s don't force the real ones into 
memory. */
   YYSTYPE *yyvs1 = yyvs;
   short *yyss1 = yyss;
-#ifdef YYLSP_NEEDED
-  YYLTYPE *yyls1 = yyls;
-#endif
 
   /* Get the current used size of the three stacks, in elements.  */
   int size = yyssp - yyss + 1;
@@ -533,25 +503,12 @@ yynewstate:
 #ifdef yyoverflow
   /* Each stack pointer address is followed by the size of
  the data in use in that stack, in bytes.  */
-#ifdef YYLSP_NEEDED
-  /* This used to be a conditional around just the two extra args,
- but that might be undefined if yyoverflow is a macro.  */
-  yyoverflow("parser stack overflow",
- , size * sizeof (*yyssp),
- , size * sizeof (*yyvsp),
- , size * sizeof (*yylsp),
- );
-#else
   yyoverflow("parser stack overflow",
  , size * sizeof (*yyssp),
  , size * sizeof (*yyvsp),
  );
-#endif
 
   yyss = yyss1; yyvs = yyvs1;
-#ifdef YYLSP_NEEDED
-  yyls = yyls1;
-#endif
 #else /* no yyoverflow */
   /* Extend the stack our own way.  */
   if (yystacksize >= YYMAXDEPTH)
@@ -561,9 +518,6 @@ yynewstate:
 {
   free (yyss);
   free (yyvs);
-#ifdef YYLSP_NEEDED
-  free (yyls);
-#endif
 }
   return 2;
 }
@@ -575,17 +529,10 @@ yynewstate:
   memcpy (yyss, yyss1, size * sizeof (*yyssp));
   yyvs = static_cast(malloc (yystacksize * sizeof (*yyvsp)));
   memcpy (yyvs, yyvs1, size * sizeof (*yyvsp));
-#ifdef YYLSP_NEEDED
-  yyls = (YYLTYPE *) malloc (yystacksize * sizeof (*yylsp));
-  memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
-#endif
 #endif /* no yyoverflow */
 
   yyssp = yyss + size - 1;
   yyvsp = yyvs + size - 1;
-#ifdef YYLSP_NEEDED
-  yylsp = yyls + size - 1;
-#endif
 
 #if YYDEBUG != 0
   if (yydebug)
@@ -696,9 +643,6 @@ yynewstate:
 yychar = YYEMPTY;
 
   *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
-  *++yylsp = yylloc;
-#endif
 
   /* count tokens shifted since error; after three, turn off error status.  */
   if (yyerrstatus) yyerrstatus--;
@@ -958,9 +902,6 @@ case 72:
 
   yyvsp -= yylen;
   yyssp -= yylen;
-#ifdef YYLSP_NEEDED
-  yylsp -= yylen;
-#endif
 
 #if YYDEBUG != 0
   if (yydebug)
@@ -975,23 +916,6 @@ case 72:
 
   *++yyvsp = yyval;
 
-#ifdef YYLSP_NEEDED
-  yylsp++;
-  if (yylen == 0)
-{
-  

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-19 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ef37fa084e55aa13ecebcd0ebdbc7c2bca908c11
Author: Caolán McNamara 
AuthorDate: Sat Mar 19 14:39:30 2022 +
Commit: Caolán McNamara 
CommitDate: Sat Mar 19 20:09:53 2022 +0100

ofz: Null-dereference READ

Change-Id: Ie42af72e321bd55e3373aca33f0bcb6884bf8836
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131849
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 13e60e21590d..8c84970867ba 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3570,7 +3570,7 @@ void HwpReader::makeFormula(TxtBox * hbox)
 pPar = hbox->plists[0].empty() ? nullptr : hbox->plists[0].front().get();
 while( pPar )
 {
-for( n = 0; n < pPar->nch && pPar->hhstr[n]->hh;
+for( n = 0; n < pPar->nch && pPar->hhstr.count(n) && 
pPar->hhstr[n]->hh;
 n += pPar->hhstr[n]->WSize() )
 {
 if (l >= sizeof(mybuf)-7)


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-18 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/grammar.cxx |3 ++-
 hwpfilter/source/lexer.cxx   |7 +++
 hwpfilter/source/lexer.hxx   |6 ++
 3 files changed, 11 insertions(+), 5 deletions(-)

New commits:
commit d643f9d5c66cdf8b6c935484e65b8f24b5ef31f0
Author: Caolán McNamara 
AuthorDate: Fri Mar 18 20:18:22 2022 +
Commit: Caolán McNamara 
CommitDate: Fri Mar 18 22:33:13 2022 +0100

ofz: Direct-leak

Change-Id: I40024334b394e4de6a1766321556689234da86ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131840
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx
index d2c91860aeb6..fdcdbb139d75 100644
--- a/hwpfilter/source/grammar.cxx
+++ b/hwpfilter/source/grammar.cxx
@@ -1175,12 +1175,13 @@ yyerrhandle:
   return 1;
 }
 
-
 Node *mainParse(const char *_code)
 {
 initFlex( _code );
 top = nullptr;
 yyparse();
+deinitFlex();
+
 if( top )
 return top;
 else
diff --git a/hwpfilter/source/lexer.cxx b/hwpfilter/source/lexer.cxx
index 5d0cef7e2f9d..191f0bce7419 100644
--- a/hwpfilter/source/lexer.cxx
+++ b/hwpfilter/source/lexer.cxx
@@ -2107,6 +2107,13 @@ void initFlex(const char *_code )
 yy_switch_to_buffer( yy_scan_string(_code) );
 }
 
+void deinitFlex()
+{
+// flex faq-memory-leak
+yy_delete_buffer(YY_CURRENT_BUFFER);
+yy_init = 1;
+}
+
 int yywrap()
 {
 yy_delete_buffer( YY_CURRENT_BUFFER );
diff --git a/hwpfilter/source/lexer.hxx b/hwpfilter/source/lexer.hxx
index 0f0c1fe1525e..41835f13b51a 100644
--- a/hwpfilter/source/lexer.hxx
+++ b/hwpfilter/source/lexer.hxx
@@ -17,13 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_HWPFILTER_SOURCE_LEXER_HXX
-#define INCLUDED_HWPFILTER_SOURCE_LEXER_HXX
+#pragma once
 
 void initFlex(char const* s);
+void deinitFlex();
 
 int yylex();
 
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-17 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 05ad57ea76b088569e5c34d5ff08342d8e894e1e
Author: Caolán McNamara 
AuthorDate: Thu Mar 17 11:50:17 2022 +
Commit: Caolán McNamara 
CommitDate: Thu Mar 17 20:48:48 2022 +0100

ofz: Null-dereference READ

Change-Id: I0e3dfed65db245779d3402293d23864b0a4fb6e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131705
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 9262b4c81d30..13e60e21590d 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3567,7 +3567,7 @@ void HwpReader::makeFormula(TxtBox * hbox)
 hchar dest[3];
 size_t l = 0;
 
-pPar = hbox->plists[0].front().get();
+pPar = hbox->plists[0].empty() ? nullptr : hbox->plists[0].front().get();
 while( pPar )
 {
 for( n = 0; n < pPar->nch && pPar->hhstr[n]->hh;


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-17 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 8e5bc762d8b1bf80e1d2fb7706b03978acc5082f
Author: Caolán McNamara 
AuthorDate: Thu Mar 17 11:45:31 2022 +
Commit: Caolán McNamara 
CommitDate: Thu Mar 17 17:27:11 2022 +0100

ofz#45598 Integer-overflow

Change-Id: Ib3c6f9af746693678f9b031a23e4a703d0615b0b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131704
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index bfdc72c704a2..9262b4c81d30 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3913,9 +3913,10 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, const Picture* hbox)
 
 basegfx::B2DPoint pt[3], r_pt[3];
 for(i = 0 ; i < 3 ; i++ ){
- pt[i].setX(pal.pt[i].x - 
drawobj->property.rot_originx);
+ basegfx::B2DPoint 
rot_origin(drawobj->property.rot_originx, drawobj->property.rot_originy);
+ pt[i].setX(pal.pt[i].x - rot_origin.getX());
  /* Convert to a physical coordinate */
- pt[i].setY(-(pal.pt[i].y - 
drawobj->property.rot_originy));
+ pt[i].setY(-(pal.pt[i].y - rot_origin.getY()));
 }
 
 double skewX;


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-17 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |   24 
 1 file changed, 12 insertions(+), 12 deletions(-)

New commits:
commit a89c16d8f37effc1be0898fc268d7b88c0157407
Author: Caolán McNamara 
AuthorDate: Thu Mar 17 11:40:19 2022 +
Commit: Caolán McNamara 
CommitDate: Thu Mar 17 17:26:51 2022 +0100

can use a reference instead of a pointer

Change-Id: I3811c9d24e4890022be7c6179148d0eac0e5525c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131703
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 5d364586310a..bfdc72c704a2 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3909,13 +3909,13 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, const Picture* hbox)
 {
 
 int i;
-ZZParall *pal = >property.parall;
+ZZParall& pal = drawobj->property.parall;
 
 basegfx::B2DPoint pt[3], r_pt[3];
 for(i = 0 ; i < 3 ; i++ ){
- pt[i].setX(pal->pt[i].x - 
drawobj->property.rot_originx);
+ pt[i].setX(pal.pt[i].x - 
drawobj->property.rot_originx);
  /* Convert to a physical coordinate */
- pt[i].setY(-(pal->pt[i].y - 
drawobj->property.rot_originy));
+ pt[i].setY(-(pal.pt[i].y - 
drawobj->property.rot_originy));
 }
 
 double skewX;
@@ -3942,20 +3942,20 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, const Picture* hbox)
 if( skewX != 0.0 && rotate != 0.0 ){
 trans = "skewX (" + OUString::number(skewX)
  + ") rotate (" + OUString::number(rotate)
- + ") translate (" + OUString::number(WTMM(x + a + 
drawobj->offset2.x + pal->pt[0].x)) + "mm "
- + OUString::number(WTMM(y + b + 
drawobj->offset2.y + pal->pt[0].y)) + "mm)";
+ + ") translate (" + OUString::number(WTMM(x + a + 
drawobj->offset2.x + pal.pt[0].x)) + "mm "
+ + OUString::number(WTMM(y + b + 
drawobj->offset2.y + pal.pt[0].y)) + "mm)";
 bIsRotate = true;
 }
 else if( skewX != 0.0 ){
 trans = "skewX (" + OUString::number(skewX)
- + ") translate (" + OUString::number(WTMM(x + a + 
drawobj->offset2.x + pal->pt[0].x)) + "mm "
- + OUString::number(WTMM(y + b + 
drawobj->offset2.y + pal->pt[0].y)) + "mm)";
+ + ") translate (" + OUString::number(WTMM(x + a + 
drawobj->offset2.x + pal.pt[0].x)) + "mm "
+ + OUString::number(WTMM(y + b + 
drawobj->offset2.y + pal.pt[0].y)) + "mm)";
 bIsRotate = true;
 }
 else if( rotate != 0.0 ){
 trans = "rotate (" + OUString::number(rotate)
- + ") translate (" + OUString::number(WTMM(x + a + 
drawobj->offset2.x + pal->pt[0].x)) + "mm "
- + OUString::number(WTMM(y + b + 
drawobj->offset2.y + pal->pt[0].y)) + "mm)";
+ + ") translate (" + OUString::number(WTMM(x + a + 
drawobj->offset2.x + pal.pt[0].x)) + "mm "
+ + OUString::number(WTMM(y + b + 
drawobj->offset2.y + pal.pt[0].y)) + "mm)";
 bIsRotate = true;
 }
 if( bIsRotate ){
@@ -4129,10 +4129,10 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, const Picture* hbox)
 
 if( drawobj->type == HWPDO_ADVANCED_ARC ){
 double start_angle, end_angle;
-ZZParall *pal = >property.parall;
+ZZParall& pal = drawobj->property.parall;
 
-start_angle = atan2(pal->pt[0].y - 
pal->pt[1].y,pal->pt[1].x - pal->pt[0].x );
-end_angle = atan2(pal->pt[2].y - pal->pt[1].y, 
pal->pt[1].x - pal->pt[2].x);
+start_angle = atan2(pal.pt[0].y - 
pal.pt[1].y,pal.pt[1].x - pal.pt[0].x );
+end_angle = atan2(pal.pt[2].y - pal.pt[1].y, 
pal.pt[1].x - pal.pt[2].x);
 
 if( ( start_angle > end_angle ) && 
(start_angle - end_angle < M_PI )){
 double tmp_angle = start_angle;


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-16 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hcode.cxx |6 ++
 hwpfilter/source/hcode.h   |2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

New commits:
commit 02f30509f8b19d862b569fab480617808f2be2a7
Author: Caolán McNamara 
AuthorDate: Wed Mar 16 09:42:37 2022 +
Commit: Caolán McNamara 
CommitDate: Wed Mar 16 11:30:57 2022 +0100

ofz#45598 Integer-overflow

Change-Id: I1b997a35630bdb3a14fe606c9a34faf4330099ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131646
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index 7a00271641b1..a02e689d28d6 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -1398,7 +1398,7 @@ OUString base64_encode_string( const uchar *buf, unsigned 
int len )
 return OUString::createFromAscii(aBuf);
 }
 
-double calcAngle(int x1, int y1, int x2, int y2)
+double calcAngle(double x1, double y1, double x2, double y2)
 {
  y1 = -y1;
  y2 = -y2;
@@ -1408,10 +1408,8 @@ double calcAngle(int x1, int y1, int x2, int y2)
   else
 return 270.;
  }
- double angle;
  // atan2 handles all 4 quadrants
- angle = basegfx::rad2deg(atan2(y2 - y1 , x2 - x1));
- return angle;
+ return basegfx::rad2deg(atan2(y2 - y1 , x2 - x1));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hcode.h b/hwpfilter/source/hcode.h
index da7ff7345913..53c1513e246f 100644
--- a/hwpfilter/source/hcode.h
+++ b/hwpfilter/source/hcode.h
@@ -69,6 +69,6 @@ DLLEXPORT OUString rgb2str(unsigned char red, unsigned char 
green, unsigned char
 DLLEXPORT OUString rgb2str(int32_t rgb);
 
 DLLEXPORT OUString base64_encode_string( const uchar *buf, unsigned int len );
-DLLEXPORT double calcAngle(int x1, int y1, int x2, int y2);
+DLLEXPORT double calcAngle(double x1, double y1, double x2, double y2);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-15 Thread Michael Stahl (via logerrit)
 hwpfilter/source/hwpread.cxx |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 4c86ed851bc1c0a2414e254082064760c99437f1
Author: Michael Stahl 
AuthorDate: Fri Mar 11 17:29:41 2022 +0100
Commit: Michael Stahl 
CommitDate: Tue Mar 15 10:58:38 2022 +0100

hwpfilter: why isn't that path string null terminated

Change-Id: Iaedc23bd91d0d46e34d55dcc65760b73c5772b7e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131559
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 85dd89a32f88..a1b9415f70b4 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -455,6 +455,7 @@ bool Picture::Read(HWPFile & hwpf)
 scale[1] = tmp16;
 
 hwpf.ReadBlock(picinfo.picun.path, 256);  /* Picture File Name: when 
type is not a Drawing. */
+picinfo.picun.path[255] = 0; // ensure null terminated
 hwpf.ReadBlock(reserved3, 9); /* Brightness / Contrast / 
Picture Effect, etc. */
 
 UpdateBBox(this);


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-14 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hbox.h|4 +++-
 hwpfilter/source/hwpreader.cxx |8 +---
 2 files changed, 8 insertions(+), 4 deletions(-)

New commits:
commit c9a4c8a8ab9933949e14de09e80333a0de6612c5
Author: Caolán McNamara 
AuthorDate: Mon Mar 14 08:54:53 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Mar 14 11:37:36 2022 +0100

ofz#45525 Null-dereference READ

Change-Id: I9d31b89fc7fa9447823ded4f6891b47100215c0a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131523
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hbox.h b/hwpfilter/source/hbox.h
index b3bdffa74911..f7813b225dd5 100644
--- a/hwpfilter/source/hbox.h
+++ b/hwpfilter/source/hbox.h
@@ -361,7 +361,9 @@ struct TxtBox: public FBox
 /**
  * Paragraph list
  */
-std::vector>> plists;
+typedef std::vector> plist_t;
+typedef std::vector plists_t;
+plists_t plists;
 
 /**
  * Caption
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 6c757409e8dc..5d364586310a 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3399,7 +3399,9 @@ void HwpReader::makeTable(TxtBox * hbox)
 mxList->addAttribute("table:protected", sXML_CDATA,"true");
 startEl("table:table-cell");
 mxList->clear();
-parsePara(hbox->plists[tcell->pCell->key].front().get());
+TxtBox::plist_t& rVec = hbox->plists[tcell->pCell->key];
+if (!rVec.empty())
+parsePara(rVec.front().get());
 endEl("table:table-cell");
 }
 endEl("table:table-row");
@@ -3513,7 +3515,7 @@ void HwpReader::makeTextBox(TxtBox * hbox)
 startEl("draw:text-box");
 mxList->clear();
 /* If captions are present and it is on the top */
-if( hbox->style.cap_len > 0 && (hbox->cap_pos % 2) && hbox->type == 
TBL_TYPE )
+if (hbox->style.cap_len > 0 && (hbox->cap_pos % 2) && hbox->type == 
TBL_TYPE && !hbox->caption.empty())
 {
 parsePara(hbox->caption.front().get());
 }
@@ -3526,7 +3528,7 @@ void HwpReader::makeTextBox(TxtBox * hbox)
 parsePara(hbox->plists[0].front().get());
 }
 /* If captions are present and it is on the bottom */
-if( hbox->style.cap_len > 0 && !(hbox->cap_pos % 2) && hbox->type == 
TBL_TYPE)
+if (hbox->style.cap_len > 0 && !(hbox->cap_pos % 2) && hbox->type == 
TBL_TYPE && !hbox->caption.empty())
 {
 parsePara(hbox->caption.front().get());
 }


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-13 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 92e3d17dbea13f1ad2f33824d0e2dc2a0a8c4014
Author: Caolán McNamara 
AuthorDate: Sun Mar 13 10:41:43 2022 +
Commit: Caolán McNamara 
CommitDate: Sun Mar 13 16:46:02 2022 +0100

ofz#45525 Null-dereference

Change-Id: If55d049f12eb00ba786f12d565081404fcdf147b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131465
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 60af8216f97b..6c757409e8dc 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3449,7 +3449,7 @@ void HwpReader::makeTextBox(TxtBox * hbox)
 OUString::number(WTMM( hbox->box_ys + hbox->cap_ys )) + "mm");
 startEl("draw:text-box");
 mxList->clear();
-if( hbox->cap_pos % 2 )   /* The caption is on the top 
*/
+if (!hbox->caption.empty() && hbox->cap_pos % 2)  /* The caption is on 
the top */
 {
 parsePara(hbox->caption.front().get());
 }


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-10 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 3edb855e7c0e2ac0d49fa38654efd92c3618ed8f
Author: Caolán McNamara 
AuthorDate: Thu Mar 10 09:12:29 2022 +
Commit: Caolán McNamara 
CommitDate: Thu Mar 10 15:36:41 2022 +0100

ofz#45385 Integer-overflow

Change-Id: I7d5e4ffa7fc2c46d7a2ad679598aa1a62a623862
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131307
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 89609e65fd5f..60af8216f97b 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3858,8 +3858,6 @@ void HwpReader::makePicture(Picture * hbox)
 
 void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, const Picture* hbox)
 {
-int x = hbox->pgx;
-int y = hbox->pgy;
 bool bIsRotate = false;
 
 while (drawobj)
@@ -3897,6 +3895,9 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, const Picture* hbox)
 }
 else
 {
+double x = hbox->pgx;
+double y = hbox->pgy;
+
 bIsRotate = false;
 if( (drawobj->property.flag & HWPDO_FLAG_ROTATION) &&
 (drawobj->property.parall.pt[0].y != 
drawobj->property.parall.pt[1].y) &&


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-09 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |   23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 6821d3ea7af00edc9e403581b029cf164dae4899
Author: Caolán McNamara 
AuthorDate: Wed Mar 9 09:15:59 2022 +
Commit: Caolán McNamara 
CommitDate: Wed Mar 9 12:00:59 2022 +0100

ofz#45385 Integer-overflow

Change-Id: If65451a787c5709d792f9972e75e353b9b09f2ea
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131233
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index c0feb4f5b61d..0db70d2aa685 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "fontmap.hxx"
 #include "formula.h"
@@ -3907,28 +3908,28 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, Picture * hbox)
 int i;
 ZZParall *pal = >property.parall;
 
-ZZPoint pt[3], r_pt[3];
+basegfx::B2DPoint pt[3], r_pt[3];
 for(i = 0 ; i < 3 ; i++ ){
- pt[i].x = pal->pt[i].x - 
drawobj->property.rot_originx;
+ pt[i].setX(pal->pt[i].x - 
drawobj->property.rot_originx);
  /* Convert to a physical coordinate */
- pt[i].y = -(pal->pt[i].y - 
drawobj->property.rot_originy);
+ pt[i].setY(-(pal->pt[i].y - 
drawobj->property.rot_originy));
 }
 
-double rotate, skewX ;
+double skewX;
 
 /* 2 - rotation angle calculation */
-rotate = atan2( pt[1].y - pt[0].y, pt[1].x - pt[0].x );
+double rotate = atan2(pt[1].getY() - pt[0].getY(), 
pt[1].getX() - pt[0].getX());
 
 for( i = 0 ; i < 3 ; i++){
- r_pt[i].x = static_cast(pt[i].x * cos(-rotate) - 
pt[i].y * sin(-rotate));
- r_pt[i].y = static_cast(pt[i].y * cos(-rotate) + 
pt[i].x * sin(-rotate));
+ r_pt[i].setX(pt[i].getX() * cos(-rotate) - 
pt[i].getY() * sin(-rotate));
+ r_pt[i].setY(pt[i].getY() * cos(-rotate) + 
pt[i].getX() * sin(-rotate));
 }
 
 /* 4 - Calculation of reflex angle */
-if( r_pt[2].y == r_pt[1].y )
+if (r_pt[2].getY() == r_pt[1].getY())
  skewX = 0;
 else
- skewX = atan(static_cast(r_pt[2].x - 
r_pt[1].x )/( r_pt[2].y - r_pt[1].y ));
+ skewX = atan((r_pt[2].getX() - r_pt[1].getX()) / 
(r_pt[2].getY() - r_pt[1].getY()));
 if( skewX >= M_PI_2 )
  skewX -= M_PI;
 if( skewX <= -M_PI_2 )
@@ -3955,8 +3956,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, Picture * hbox)
 bIsRotate = true;
 }
 if( bIsRotate ){
-drawobj->extent.w = 
static_cast(std::hypot(pt[1].x-pt[0].x, pt[1].y-pt[0].y));
-drawobj->extent.h = 
static_cast(std::hypot(pt[2].x-pt[1].x, pt[2].y-pt[1].y));
+drawobj->extent.w = 
static_cast(std::hypot(pt[1].getX() - pt[0].getX(), pt[1].getY() - 
pt[0].getY()));
+drawobj->extent.h = 
static_cast(std::hypot(pt[2].getX() - pt[1].getX(), pt[2].getY() - 
pt[1].getY()));
 mxList->addAttribute("draw:transform", sXML_CDATA, trans);
 }
 }


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-07 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hbox.cxx |   32 +---
 1 file changed, 25 insertions(+), 7 deletions(-)

New commits:
commit 685956b45355324f7fef1c9bfc514a4dcf58b35b
Author: Caolán McNamara 
AuthorDate: Mon Mar 7 09:42:08 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Mar 7 13:38:14 2022 +0100

ofz#45314 limit to valid day/month indexes

Change-Id: Ibf53fa1a0c1db3046a25367fb79da3b90f7cd924
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131098
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index c17f3f6f9742..ed477155f7b9 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -173,13 +173,20 @@ hchar_string DateCode::GetString()
 num = date[MONTH];
 break;
 case '@':
-memcpy(cbuf, eng_mon + (date[MONTH] - 1) * 3, 3);
+{
+static_assert((std::size(eng_mon) - 1) / 3 == 12);
+size_t nIndex = (date[MONTH] - 1) % 12;
+memcpy(cbuf, eng_mon + nIndex * 3, 3);
 cbuf[3] = '.';
 cbuf[4] = 0;
-break;
+break;
+}
 case '*':
-strncat(cbuf, en_mon[date[MONTH] - 1], sizeof(cbuf) - strlen(cbuf) 
- 1);
+{
+size_t nIndex = (date[MONTH] - 1) % std::size(en_mon);
+strncat(cbuf, en_mon[nIndex], sizeof(cbuf) - strlen(cbuf) - 1);
 break;
+}
 case '3': /* 'D' is day of korean */
 num = date[DAY];
 break;
@@ -212,16 +219,26 @@ hchar_string DateCode::GetString()
 num = date[MIN];
 break;
 case '6':
-ret.push_back(kor_week[date[WEEK]]);
+{
+size_t nIndex = date[WEEK] % std::size(kor_week);
+ret.push_back(kor_week[nIndex]);
 break;
+}
 case '^':
-memcpy(cbuf, eng_week + date[WEEK] * 3, 3);
+{
+static_assert((std::size(eng_week) - 1) / 3 == 7);
+size_t nIndex = date[WEEK] % 7;
+memcpy(cbuf, eng_week + nIndex * 3, 3);
 cbuf[3] = '.';
 cbuf[4] = 0;
 break;
+}
 case '_':
-strncat(cbuf, en_week[date[WEEK]], sizeof(cbuf) - strlen(cbuf) - 
1);
+{
+size_t nIndex = date[WEEK] % std::size(en_week);
+strncat(cbuf, en_week[nIndex], sizeof(cbuf) - strlen(cbuf) - 1);
 break;
+}
 case '7':
 ret.push_back(0xB5A1);
 ret.push_back(is_pm ? 0xD281 : 0xB8E5);
@@ -257,7 +274,8 @@ hchar_string DateCode::GetString()
 fmt++;
 if (*fmt == '6')
 {
-ret.push_back(china_week[date[WEEK]]);
+size_t nIndex = date[WEEK] % std::size(china_week);
+ret.push_back(china_week[nIndex]);
 break;
 }
 break;


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-07 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit f6f665200c3ac6d046194ea25535c25d00717378
Author: Caolán McNamara 
AuthorDate: Mon Mar 7 09:05:33 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Mar 7 10:53:25 2022 +0100

ofz: Null-dereference

Change-Id: I11213a5ab05389b7c5020d878b0f657045693e30
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131094
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index a20d71b5c5c3..c0feb4f5b61d 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3696,7 +3696,7 @@ void HwpReader::makePicture(Picture * hbox)
 OUString::number(WTMM( hbox->box_ys + 
hbox->style.margin[1][2] + hbox->style.margin[1][3] + hbox->cap_ys )) + "mm");
 startEl("draw:text-box");
 mxList->clear();
-if( hbox->cap_pos % 2 )   /* Caption is on the top */
+if (!hbox->caption.empty() && hbox->cap_pos % 2)   /* 
Caption is on the top */
 {
 parsePara(hbox->caption.front().get());
 }


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-05 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |   36 
 1 file changed, 20 insertions(+), 16 deletions(-)

New commits:
commit 94e8b4b6a5ca957e1426f47cda898f175932183c
Author: Caolán McNamara 
AuthorDate: Sat Mar 5 14:05:54 2022 +
Commit: Caolán McNamara 
CommitDate: Sat Mar 5 21:42:20 2022 +0100

ofz#45167 Integer-overflow

Change-Id: Ib112686b192558421419a8695db9c3f35c5312da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131058
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index ff551174219f..a20d71b5c5c3 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -4054,22 +4054,26 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, Picture * hbox)
 mxList->addAttribute("svg:height", sXML_CDATA,
  OUString::number (WTMM( drawobj->extent.h )) 
+ "mm");
 if( drawobj->type == HWPDO_ADVANCED_ELLIPSE ){
-if( drawobj->u.arc.radial[0].x != 
drawobj->u.arc.radial[1].x
-|| drawobj->u.arc.radial[0].y != 
drawobj->u.arc.radial[1].y ){
-int Cx,Cy;
-Cx = ( drawobj->offset2.x + 
drawobj->extent.w ) / 2;
-Cy = ( drawobj->offset2.y + 
drawobj->extent.h ) / 2;
-
-double start_angle, end_angle;
-start_angle = calcAngle( Cx, Cy, 
drawobj->u.arc.radial[0].x, drawobj->u.arc.radial[0].y );
-end_angle = calcAngle( Cx, Cy, 
drawobj->u.arc.radial[1].x, drawobj->u.arc.radial[1].y );
-if( drawobj->property.fill_color < 
0xff )
-mxList->addAttribute("draw:kind", 
sXML_CDATA, "section");
-else
-mxList->addAttribute("draw:kind", 
sXML_CDATA, "arc");
-mxList->addAttribute("draw:start-angle", 
sXML_CDATA, OUString::number(start_angle ));
-mxList->addAttribute("draw:end-angle", 
sXML_CDATA, OUString::number(end_angle));
-}
+if (drawobj->u.arc.radial[0].x != 
drawobj->u.arc.radial[1].x ||
+drawobj->u.arc.radial[0].y != 
drawobj->u.arc.radial[1].y) {
+
+int Cx, Cy;
+if (!o3tl::checked_add(drawobj->offset2.x, 
drawobj->extent.w, Cx) &&
+!o3tl::checked_add(drawobj->offset2.y, 
drawobj->extent.h, Cy))
+{
+Cx /= 2;
+Cy /= 2;
+
+double start_angle = calcAngle( Cx, Cy, 
drawobj->u.arc.radial[0].x, drawobj->u.arc.radial[0].y );
+double end_angle = calcAngle( Cx, Cy, 
drawobj->u.arc.radial[1].x, drawobj->u.arc.radial[1].y );
+if( drawobj->property.fill_color < 0xff )
+mxList->addAttribute("draw:kind", 
sXML_CDATA, "section");
+else
+mxList->addAttribute("draw:kind", 
sXML_CDATA, "arc");
+mxList->addAttribute("draw:start-angle", 
sXML_CDATA, OUString::number(start_angle ));
+mxList->addAttribute("draw:end-angle", 
sXML_CDATA, OUString::number(end_angle));
+}
+}
 }
 startEl("draw:ellipse");
 mxList->clear();


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-04 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hwpreader.cxx |   22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

New commits:
commit e001a86393e363261617d2521b516287561905d4
Author: Mike Kaganski 
AuthorDate: Fri Mar 4 19:55:14 2022 +0300
Commit: Mike Kaganski 
CommitDate: Sat Mar 5 06:22:06 2022 +0100

Use rtl::isAsciiDigit instead of custom macro

Change-Id: Iabca31825dd47cee661b47b14f09e96459a42015
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131033
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index d6fdf29d1407..ff551174219f 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 // xmloff/xmlkyd.hxx
@@ -222,7 +223,6 @@ void HwpReader::makeTextDecls()
 }
 
 
-#define ISNUMBER(x) ( (x) <= 0x39 && (x) >= 0x30 )
 /**
  * make office:meta
  * Completed
@@ -259,8 +259,8 @@ void HwpReader::makeMeta()
 unsigned short *pDate = hwpinfo.summary.date;
 int year,month,day,hour,minute;
 int gab = 0;
-if( ISNUMBER( pDate[0] ) && ISNUMBER( pDate[1] ) &&
-ISNUMBER( pDate[2] ) && ISNUMBER( pDate[3] ))
+if( rtl::isAsciiDigit( pDate[0] ) && rtl::isAsciiDigit( pDate[1] ) &&
+rtl::isAsciiDigit( pDate[2] ) && rtl::isAsciiDigit( pDate[3] ))
 {
 year = (pDate[0]-0x30) * 1000 + (pDate[1]-0x30) * 100 +
 (pDate[2]-0x30) * 10 + (pDate[3]-0x30);
@@ -268,9 +268,9 @@ void HwpReader::makeMeta()
 else {
 year = 0;
 }
-if( ISNUMBER( pDate[6] ))
+if( rtl::isAsciiDigit( pDate[6] ))
 {
-if( ISNUMBER( pDate[7] ) )
+if( rtl::isAsciiDigit( pDate[7] ) )
 month = (pDate[6] - 0x30) * 10 + (pDate[6+ ++gab]-0x30);
 else
 month = (pDate[6] - 0x30);
@@ -278,9 +278,9 @@ void HwpReader::makeMeta()
 else {
 month = 0;
 }
-if( ISNUMBER( pDate[9 + gab] ) )
+if( rtl::isAsciiDigit( pDate[9 + gab] ) )
 {
-if( ISNUMBER( pDate[10 + gab])) {
+if( rtl::isAsciiDigit( pDate[10 + gab])) {
 day = ( pDate[9 + gab] - 0x30 ) * 10 + (pDate[9+ gab + 
1]-0x30);
 ++gab;
 } else
@@ -289,9 +289,9 @@ void HwpReader::makeMeta()
 else {
 day = 0;
 }
-if( ISNUMBER( pDate[17 + gab] ) )
+if( rtl::isAsciiDigit( pDate[17 + gab] ) )
 {
-if( ISNUMBER( pDate[18 + gab])) {
+if( rtl::isAsciiDigit( pDate[18 + gab])) {
 hour = ( pDate[17 + gab] - 0x30 ) * 10 + (pDate[17+ gab + 
1]-0x30);
 ++gab;
 } else
@@ -300,9 +300,9 @@ void HwpReader::makeMeta()
 else {
 hour = 0;
 }
-if( ISNUMBER( pDate[20 + gab] ) )
+if( rtl::isAsciiDigit( pDate[20 + gab] ) )
 {
-if( ISNUMBER( pDate[21 + gab])) {
+if( rtl::isAsciiDigit( pDate[21 + gab])) {
 minute = ( pDate[20 + gab] - 0x30 ) * 10 + (pDate[20+ gab + 
1]-0x30);
 ++gab;
 } else


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-04 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hwpreader.cxx |  142 +
 1 file changed, 76 insertions(+), 66 deletions(-)

New commits:
commit 2c82ed241648dadd8326f0847479a4959385a6f1
Author: Mike Kaganski 
AuthorDate: Fri Mar 4 16:01:17 2022 +0300
Commit: Mike Kaganski 
CommitDate: Sat Mar 5 06:21:47 2022 +0100

Convert some macros to local lambdas

Change-Id: I22942588c7e7ebfb3f53cc5739d2bbd9a7ccfd41
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130983
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index cb484b4fa814..d6fdf29d1407 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -42,23 +42,6 @@
 // xmloff/xmlkyd.hxx
 constexpr OUStringLiteral sXML_CDATA = u"CDATA";
 
-#define STARTP  mxList->addAttribute( "text:style-name", "CDATA", 
getPStyleName((para->GetParaShape()).index)); \
-startEl("text:p"); \
-mxList->clear(); \
-pstart = true
-#define STARTT \
-curr = para->GetCharShape(n > 0 ? n-1 : 0)->index; \
-mxList->addAttribute( "text:style-name", "CDATA" , getTStyleName(curr) ); \
-startEl("text:span"); \
-mxList->clear(); \
-tstart = true
-#define ENDP \
-endEl("text:p"); \
-pstart = false
-#define ENDT \
-endEl("text:span"); \
-tstart = false
-
 static hchar *field = nullptr;
 static char buf[1024];
 
@@ -2772,11 +2755,38 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 bool pstart = bParaStart;
 bool tstart = false;
 bool infield = false;
-int curr;
+
+const auto STARTP = [this, para, ]()
+{
+mxList->addAttribute("text:style-name", "CDATA",
+ getPStyleName(para->GetParaShape().index));
+startEl("text:p");
+mxList->clear();
+pstart = true;
+};
+const auto STARTT = [this, para, ](int pos)
+{
+auto curr = para->GetCharShape(pos > 0 ? pos - 1 : 0)->index;
+mxList->addAttribute("text:style-name", "CDATA", getTStyleName(curr));
+startEl("text:span");
+mxList->clear();
+tstart = true;
+};
+const auto ENDP = [this, ]()
+{
+endEl("text:p");
+pstart = false;
+};
+const auto ENDT = [this, ]()
+{
+endEl("text:span");
+tstart = false;
+};
+
 if( d->bFirstPara && d->bInBody )
 {
 if ( !pstart ) {
-STARTP;
+STARTP();
 }
 mxList->addAttribute("text:name", sXML_CDATA, sBeginOfDoc);
 startEl("text:bookmark");
@@ -2787,7 +2797,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 if( d->bInHeader )
 {
 if ( !pstart ) {
-STARTP;
+STARTP();
 }
 makeShowPageNum();
 d->bInHeader = false;
@@ -2800,19 +2810,19 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 {
 if (!str.empty())
 {
-if( !pstart ){ STARTP;}
-if( !tstart ){ STARTT;}
+if( !pstart ){ STARTP(); }
+if( !tstart ){ STARTT(n);}
 makeChars(str);
 }
-if( tstart ){ ENDT;}
-if( !pstart ){ STARTP;}
-if( pstart ){ ENDP;}
+if( tstart ){ ENDT();}
+if( !pstart ){ STARTP(); }
+if( pstart ){ ENDP(); }
 break;
 }
 else if( para->hhstr[n]->hh == CH_SPACE  && !firstspace)
 {
-if( !pstart ) {STARTP;}
-if( !tstart ) {STARTT;}
+if( !pstart ) {STARTP(); }
+if( !tstart ) {STARTT(n);}
 makeChars(str);
 startEl("text:s");
 mxList->clear();
@@ -2823,10 +2833,10 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 if( n > 0 )
 if( para->GetCharShape(n)->index != 
para->GetCharShape(n-1)->index && !infield )
 {
- if( !pstart ) {STARTP;}
- if( !tstart ) {STARTT;}
+ if( !pstart ) {STARTP(); }
+ if( !tstart ) {STARTT(n);}
  makeChars(str);
- ENDT;
+ ENDT();
 }
 if( para->hhstr[n]->hh == CH_SPACE )
 firstspace = 0;
@@ -2843,8 +2853,8 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 FieldCode *hbox = static_cast(para->hhstr[n].get());
 if( hbox->location_info == 1)
 {
-if( !pstart ) {STARTP;}
-if( !tstart ) {STARTT;}
+if( !pstart ) {STARTP(); }
+if( !tstart ) {STARTT(n);}
 makeChars(str);
 firstspace = 1;
 if( hbox->type[0] == 4 && hbox->type[1] == 0 )
@@ -2873,24 +2883,24 @@ void 

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-04 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hinfo.h |   44 ++--
 1 file changed, 22 insertions(+), 22 deletions(-)

New commits:
commit 35428625b70829ba56da99fafe205b24b0018ace
Author: Mike Kaganski 
AuthorDate: Fri Mar 4 19:24:34 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 4 22:02:39 2022 +0100

Restore damaged comments

They were broken in commit d1af3a5fc102f9bb3464541d83ef0fa4bb2ce2a1

  Author Vladimir Glazounov 
  Date   Wed Jun 04 09:02:42 2008 +

INTEGRATION: CWS sw30bf04 (1.4.2); FILE MERGED

It changed the original EUC-KR file encoding to ASCII.

Change-Id: I423b6e7dac0a47ad7688175780f062ecaefb9101
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131027
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hinfo.h b/hwpfilter/source/hinfo.h
index c0381787f7d9..57067646c856 100644
--- a/hwpfilter/source/hinfo.h
+++ b/hwpfilter/source/hinfo.h
@@ -65,19 +65,19 @@ struct PaperInfo
 }
 };
 
-/* ?? ??,   */
+/* 페이지 배경색, 배경그림 정보 */
 struct PaperBackInfo
 {
 char type;  // 0- background color, 1 - external image, 2- embedded image
 char reserved1[8] = {};
-int luminance; /*  ( -100 ~ 100 ) */
-int contrast; /*  ( -100 ~ 100 ) */
-char effect; /* 0-, 1-, 2- */
+int luminance; /* 밝기 ( -100 ~ 100 ) */
+int contrast; /* 명암 ( -100 ~ 100 ) */
+char effect; /* 0-원래그림, 1-그레이스케일, 2-흑백 */
 char reserved2[8] = {};
 char filename[260 + 1] = {}; // filename
 unsigned char color[3] = {}; //0 - red, 1 - green, 2 - blue
-unsigned short flag; /* 0 - , 1 - , 2 - ??, 3 - 
 */
-int range; /* 0-, 1-, 3-??, 4-?? */
+unsigned short flag; /* 0 - 바둑판식, 1 - 가운데로, 2 - 쪽크기, 3 - 용지크기 */
+int range; /* 0-전체, 1-첫페이지, 3-짝수쪽, 4-홀수쪽 */
 char reserved3[27] = {};
 int size;
 std::vector data;// image data
@@ -95,7 +95,7 @@ struct PaperBackInfo
 }
 };
 
-/*   */
+/* 연결인쇄 정보 */
 /**
  * Information of printing for chained page
  */
@@ -111,7 +111,7 @@ struct DocChainInfo
 }
 };
 
-/*   */
+/* 문서 요약 */
 /**
  * Summary of document
  */
@@ -128,13 +128,13 @@ struct HWPSummary
 };
 
 /**
-  HWPInfo class?? HWPFile??  ??   ??.
-  ??   (layout) ?? 
-  ,   ??  . \\
+  HWPInfo class는 HWPFile에 대한 정보를 담고 있는 클래스이다.
+  종이나 여백 등의 레이아웃(layout) 정보는 쪽매기기에서
+  사용하며, 기타 내부 정보를 포함하고 있다. \\
 
-  HWPInfo  HWPFile?? #GetHWPInfo()# ??   ?? .
+  HWPInfo 클래스는 HWPFile의 #GetHWPInfo()# 함수를 통해 얻을 수 있다.
 
-  @memo Hwp  
+  @memo Hwp 문서 정보
 */
 /**
  * Contains the basic information of the hwp document:
@@ -169,12 +169,12 @@ class DLLEXPORT HWPInfo
 unsigned char annotation[ANNOTATION_LEN] = {};
 short encrypted;
 // unsigned charreserved2[6];
-short beginpagenum;   /* ??  */
+short beginpagenum;   /* 시작페이지 번호 */
 /**
  * Information about footnote
  */
-short beginfnnum; /*  */
-short countfn;/*   */
+short beginfnnum; /* 각주시작번호 */
+short countfn;/* 각주 갯수 */
 hunit splinetext, splinefn;
 hunit spfnfn;
 unsigned char fnchar;
@@ -191,7 +191,7 @@ class DLLEXPORT HWPInfo
 unsigned char compressed;
 unsigned char reserved3;
 short info_block_len;
-/* ?? 128 ?? */
+/* 여기까지가 128 바이트이다 */
 /**
  * Summary of document
  */
@@ -205,7 +205,7 @@ class DLLEXPORT HWPInfo
 
 };
 
-/*   ?? */
+/* 글자 모양 구조체 */
 /**
  * @short Style of character
  */
@@ -214,14 +214,14 @@ struct CharShape
 /**
  * Index of character style
  */
-int   index;  /*   . */
+int   index;  /* 스타일의 인덱스를 저장. */
 /**
  * Font size
  */
 hunit size;
 unsigned char font[NLanguage];
 unsigned char ratio[NLanguage];
-signed char   space[NLanguage];   /*  */
+signed char   space[NLanguage];   /* 자간 */
 unsigned char color[2];
 unsigned char shade;
 unsigned char attr;
@@ -232,7 +232,7 @@ struct CharShape
 CharShape();
 };
 
-/* ?? ??  ?? */
+/* 탭 설정에 대한 구조체 */
 
 #define MAXTABS 40
 /**
@@ -278,7 +278,7 @@ struct ParaShape
 /**
  * Index of paragraph style
  */
-int   index;  /*    */
+int   index;  /* 스타일의 인덱스를 저장 */
 hunit left_margin;
 hunit right_margin;
 hunit indent;


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-04 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hwpreader.cxx |   25 +++--
 1 file changed, 7 insertions(+), 18 deletions(-)

New commits:
commit 3dfd6657db5e4a1706004c006ebf6c40b23830f9
Author: Mike Kaganski 
AuthorDate: Fri Mar 4 15:30:11 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 4 22:00:42 2022 +0100

Turn conversion macros to proper functions

Change-Id: I463dff95d81e497bafacb60268288bf7526fb3d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130979
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 0f77c8df9746..9bb15364a0c3 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -39,11 +39,6 @@
 #include 
 #include 
 
-// To be shorten source code by realking
-#define WTI(x)  (static_cast(x) / 1800.) // unit => inch
-#define WTMM(x) (static_cast(x) / 1800. * 25.4)  // unit => mm
-#define WTSM(x) (static_cast((x) / 1800. * 2540))   // unit ==> 1/100 
mm
-
 // xmloff/xmlkyd.hxx
 constexpr OUStringLiteral sXML_CDATA = u"CDATA";
 
@@ -69,15 +64,9 @@ static char buf[1024];
 
 namespace
 {
-
-template
-struct Free
-{
-void operator()(T* const ptr)
-{
-free(ptr);
-}
-};
+double WTI(double x) { return x / 1800.; } // unit => inch
+double WTMM(double x) { return x / 1800. * 25.4; } // unit => mm
+int WTSM(double x) { return x / 1800. * 2540; } // unit ==> 1/100 mm
 
 constexpr OUStringLiteral sBeginOfDoc(u"[\uBB38\uC11C\uC758 \uCC98\uC74C]");
 // U+BB38 HANGUL SYLLABLE MUN, U+C11C HANGUL SYLLABLE SEO,
@@ -3439,14 +3428,14 @@ void HwpReader::makeTextBox(TxtBox * hbox)
 if (hbox->style.anchor_type != CHAR_ANCHOR)
 {
 mxList->addAttribute("svg:x", sXML_CDATA,
-OUString::number(WTMM( ( hbox->pgx + hbox->style.margin[0][0] 
) )) + "mm");
+OUString::number(WTMM( hbox->pgx + hbox->style.margin[0][0] )) 
+ "mm");
 mxList->addAttribute("svg:y", sXML_CDATA,
-OUString::number(WTMM( ( hbox->pgy + hbox->style.margin[0][2] 
) )) + "mm");
+OUString::number(WTMM( hbox->pgy + hbox->style.margin[0][2] )) 
+ "mm");
 }
 mxList->addAttribute("svg:width", sXML_CDATA,
-OUString::number(WTMM(( hbox->box_xs + hbox->cap_xs) )) + "mm");
+OUString::number(WTMM( hbox->box_xs + hbox->cap_xs )) + "mm");
 mxList->addAttribute("fo:min-height", sXML_CDATA,
-OUString::number(WTMM(( hbox->box_ys + hbox->cap_ys) )) + "mm");
+OUString::number(WTMM( hbox->box_ys + hbox->cap_ys )) + "mm");
 startEl("draw:text-box");
 mxList->clear();
 if( hbox->cap_pos % 2 )   /* The caption is on the top 
*/


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-04 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hcode.cxx |8 +
 hwpfilter/source/hcode.h   |2 +
 hwpfilter/source/hwpreader.cxx |   60 +++--
 3 files changed, 27 insertions(+), 43 deletions(-)

New commits:
commit 823fe1cb509e80f36744ff948d506ec9eeffb752
Author: Mike Kaganski 
AuthorDate: Fri Mar 4 18:57:46 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 4 21:59:56 2022 +0100

Avoid some sprintf used with colors

Also addresses possible buffer overflow because of possible
color channel values greater than 255 (found by a fuzzer;
likely by some unexpected value of shade exceeding 100; see

https://gerrit.libreoffice.org/c/core/+/130956/3/hwpfilter/source/hcode.cxx#1292)

Change-Id: I168685c3b51cbc8c9f664282bc9378b3c6669ba0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131003
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index 3e9b08086f23..7a00271641b1 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -1288,13 +1288,21 @@ OUString hcolor2str(uchar color, uchar shade, bool 
bIsChar)
 blue = 0xff;
 break;
 }
+return rgb2str(red, green, blue);
+}
+
 
+OUString rgb2str(unsigned char red, unsigned char green, unsigned char blue)
+{
 char buf[8];
 int n = std::max(sprintf(buf, "#%02x%02x%02x", red, green, blue), 0);
 return OUString::createFromAscii(std::string_view(buf, n));
 }
 
 
+OUString rgb2str(int32_t rgb) { return rgb2str(rgb & 0xff, (rgb >> 8) & 0xff, 
(rgb >> 16) & 0xff); }
+
+
 ::std::string urltounix(const char *src)
 {
 ::std::string ret;
diff --git a/hwpfilter/source/hcode.h b/hwpfilter/source/hcode.h
index 0f8362e0128a..da7ff7345913 100644
--- a/hwpfilter/source/hcode.h
+++ b/hwpfilter/source/hcode.h
@@ -65,6 +65,8 @@ DLLEXPORT ::std::string urltowin(const char *src);
  * color인덱스 값과 음영값을 조합하여 스타오피스의 color로 변환
  */
 DLLEXPORT OUString hcolor2str(uchar color, uchar shade, bool bIsChar = false);
+DLLEXPORT OUString rgb2str(unsigned char red, unsigned char green, unsigned 
char blue);
+DLLEXPORT OUString rgb2str(int32_t rgb);
 
 DLLEXPORT OUString base64_encode_string( const uchar *buf, unsigned int len );
 DLLEXPORT double calcAngle(int x1, int y1, int x2, int y2);
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index f971eeae8c58..0f77c8df9746 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -585,32 +585,19 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 {
 if( prop->center_y == 100 )
 {
-sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
-(prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) 
& 0xff );
-mxList->addAttribute( "draw:start-color", sXML_CDATA, 
OUString::createFromAscii( buf ));
-sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
-(prop->fromcolor >> 8) & 0xff, (prop->fromcolor 
>>16) & 0xff );
-mxList->addAttribute( "draw:end-color", sXML_CDATA, 
OUString::createFromAscii( buf ));
+mxList->addAttribute( "draw:start-color", sXML_CDATA, 
rgb2str( prop->tocolor ));
+mxList->addAttribute( "draw:end-color", sXML_CDATA, 
rgb2str( prop->fromcolor ));
 }
 else
 {
-sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
-(prop->fromcolor >> 8) & 0xff, (prop->fromcolor 
>>16) & 0xff );
-mxList->addAttribute( "draw:start-color", sXML_CDATA, 
OUString::createFromAscii( buf ));
-sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
-(prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) 
& 0xff );
-mxList->addAttribute( "draw:end-color", sXML_CDATA, 
OUString::createFromAscii( buf ));
+mxList->addAttribute( "draw:start-color", sXML_CDATA, 
rgb2str( prop->fromcolor ));
+mxList->addAttribute( "draw:end-color", sXML_CDATA, 
rgb2str( prop->tocolor ));
 }
 }
 else
 {
-sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
-(prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) & 
0xff );
-mxList->addAttribute( "draw:start-color", 
sXML_CDATA,OUString::createFromAscii( buf ));
-
-sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
-(prop->fromcolor >> 8) & 0xff, (prop->fromcolor >>16) 
& 0xff );
-mxList->addAttribute( "draw:end-color", 
sXML_CDATA,OUString::createFromAscii( buf ));
+

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-04 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hwpreader.cxx |  896 -
 hwpfilter/source/hwpreader.hxx |4 
 2 files changed, 461 insertions(+), 439 deletions(-)

New commits:
commit 0253b5106d597690ef55fbce56065a39b27bc5e5
Author: Mike Kaganski 
AuthorDate: Fri Mar 4 12:18:15 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 4 13:28:55 2022 +0100

Convert rstartEl/rendEl/rchars macros to proper methods

Change-Id: I0cdb7d0047e153b4eb6f6a1fc0bb09c116366b7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130959
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index c066d19fe694..f971eeae8c58 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -40,9 +40,6 @@
 #include 
 
 // To be shorten source code by realking
-#define rstartEl(x,y)   do { if (m_rxDocumentHandler.is()) 
m_rxDocumentHandler->startElement(x,y); } while(false)
-#define rendEl(x)   do { if (m_rxDocumentHandler.is()) 
m_rxDocumentHandler->endElement(x); } while(false)
-#define rchars(x)   do { if (m_rxDocumentHandler.is()) 
m_rxDocumentHandler->characters(x); } while(false)
 #define WTI(x)  (static_cast(x) / 1800.) // unit => inch
 #define WTMM(x) (static_cast(x) / 1800. * 25.4)  // unit => mm
 #define WTSM(x) (static_cast((x) / 1800. * 2540))   // unit ==> 1/100 
mm
@@ -51,20 +48,20 @@
 constexpr OUStringLiteral sXML_CDATA = u"CDATA";
 
 #define STARTP  mxList->addAttribute( "text:style-name", "CDATA", 
getPStyleName((para->GetParaShape()).index)); \
-rstartEl( "text:p",mxList ); \
+startEl("text:p"); \
 mxList->clear(); \
 pstart = true
 #define STARTT \
 curr = para->GetCharShape(n > 0 ? n-1 : 0)->index; \
 mxList->addAttribute( "text:style-name", "CDATA" , getTStyleName(curr) ); \
-rstartEl( "text:span",mxList ); \
+startEl("text:span"); \
 mxList->clear(); \
 tstart = true
 #define ENDP \
-rendEl("text:p"); \
+endEl("text:p"); \
 pstart = false
 #define ENDT \
-rendEl("text:span"); \
+endEl("text:span"); \
 tstart = false
 
 static hchar *field = nullptr;
@@ -167,7 +164,7 @@ bool HwpReader::importHStream(std::unique_ptr 
stream)
 mxList->addAttribute("xmlns:form", "CDATA", 
"http://openoffice.org/2000/form;);
 mxList->addAttribute("xmlns:script", "CDATA", 
"http://openoffice.org/2000/script;);
 
-rstartEl("office:document", mxList);
+startEl("office:document");
 mxList->clear();
 
 makeMeta();
@@ -176,7 +173,7 @@ bool HwpReader::importHStream(std::unique_ptr 
stream)
 makeMasterStyles();
 makeBody();
 
-rendEl("office:document");
+endEl("office:document");
 
 if (m_rxDocumentHandler.is())
 m_rxDocumentHandler->endDocument();
@@ -213,12 +210,12 @@ sal_Bool HwpReader::filter(const Sequence< PropertyValue 
>& rDescriptor)
  */
 void HwpReader::makeBody()
 {
-rstartEl("office:body", mxList);
+startEl("office:body");
 makeTextDecls();
 HWPPara *hwppara = hwpfile.GetFirstPara();
 d->bInBody = true;
 parsePara(hwppara);
-rendEl("office:body");
+endEl("office:body");
 d->bInBody = false;
 }
 
@@ -228,28 +225,28 @@ void HwpReader::makeBody()
  */
 void HwpReader::makeTextDecls()
 {
-rstartEl("text:sequence-decls", mxList);
+startEl("text:sequence-decls");
 mxList->addAttribute("text:display-outline-level", sXML_CDATA, "0");
 mxList->addAttribute("text:name", sXML_CDATA, "Illustration");
-rstartEl("text:sequence-decl", mxList);
+startEl("text:sequence-decl");
 mxList->clear();
-rendEl("text:sequence-decl");
+endEl("text:sequence-decl");
 mxList->addAttribute("text:display-outline-level", sXML_CDATA, "0");
 mxList->addAttribute("text:name", sXML_CDATA, "Table");
-rstartEl("text:sequence-decl", mxList);
+startEl("text:sequence-decl");
 mxList->clear();
-rendEl("text:sequence-decl");
+endEl("text:sequence-decl");
 mxList->addAttribute("text:display-outline-level", sXML_CDATA, "0");
 mxList->addAttribute("text:name", sXML_CDATA, "Text");
-rstartEl("text:sequence-decl", mxList);
+startEl("text:sequence-decl");
 mxList->clear();
-rendEl("text:sequence-decl");
+endEl("text:sequence-decl");
 mxList->addAttribute("text:display-outline-level", sXML_CDATA, "0");
 mxList->addAttribute("text:name", sXML_CDATA, "Drawing");
-rstartEl("text:sequence-decl", mxList);
+startEl("text:sequence-decl");
 mxList->clear();
-rendEl("text:sequence-decl");
-rendEl("text:sequence-decls");
+endEl("text:sequence-decl");
+endEl("text:sequence-decls");
 }
 
 
@@ -262,27 +259,27 @@ void HwpReader::makeMeta()
 {
 HWPInfo& hwpinfo = hwpfile.GetHWPInfo();
 
-rstartEl("office:meta", mxList);
+startEl("office:meta");
 
 if (hwpinfo.summary.title[0])
 {
-rstartEl("dc:title", mxList);
-

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-04 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hwpreader.cxx | 1333 -
 1 file changed, 666 insertions(+), 667 deletions(-)

New commits:
commit 3367ac3093acca7d220502d0fca97678cfd62a23
Author: Mike Kaganski 
AuthorDate: Fri Mar 4 11:53:37 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 4 12:58:13 2022 +0100

Expand padd macro

Change-Id: Ic3a5bbb872ae36151aed5c108f7694cb4a12495e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130958
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 1d7b95479fee..c066d19fe694 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -43,7 +43,6 @@
 #define rstartEl(x,y)   do { if (m_rxDocumentHandler.is()) 
m_rxDocumentHandler->startElement(x,y); } while(false)
 #define rendEl(x)   do { if (m_rxDocumentHandler.is()) 
m_rxDocumentHandler->endElement(x); } while(false)
 #define rchars(x)   do { if (m_rxDocumentHandler.is()) 
m_rxDocumentHandler->characters(x); } while(false)
-#define padd(x,y,z) mxList->addAttribute(x,y,z)
 #define WTI(x)  (static_cast(x) / 1800.) // unit => inch
 #define WTMM(x) (static_cast(x) / 1800. * 25.4)  // unit => mm
 #define WTSM(x) (static_cast((x) / 1800. * 2540))   // unit ==> 1/100 
mm
@@ -51,13 +50,13 @@
 // xmloff/xmlkyd.hxx
 constexpr OUStringLiteral sXML_CDATA = u"CDATA";
 
-#define STARTP  padd( "text:style-name", "CDATA", 
getPStyleName((para->GetParaShape()).index)); \
+#define STARTP  mxList->addAttribute( "text:style-name", "CDATA", 
getPStyleName((para->GetParaShape()).index)); \
 rstartEl( "text:p",mxList ); \
 mxList->clear(); \
 pstart = true
 #define STARTT \
 curr = para->GetCharShape(n > 0 ? n-1 : 0)->index; \
-padd( "text:style-name", "CDATA" , getTStyleName(curr) ); \
+mxList->addAttribute( "text:style-name", "CDATA" , getTStyleName(curr) ); \
 rstartEl( "text:span",mxList ); \
 mxList->clear(); \
 tstart = true
@@ -148,25 +147,25 @@ bool HwpReader::importHStream(std::unique_ptr 
stream)
 if (m_rxDocumentHandler.is())
 m_rxDocumentHandler->startDocument();
 
-padd("office:class", sXML_CDATA, "text");
-padd("office:version", sXML_CDATA, "0.9");
-
-padd("xmlns:office", "CDATA", "http://openoffice.org/2000/office;);
-padd("xmlns:style", "CDATA", "http://openoffice.org/2000/style;);
-padd("xmlns:text", "CDATA", "http://openoffice.org/2000/text;);
-padd("xmlns:table", "CDATA", "http://openoffice.org/2000/table;);
-padd("xmlns:draw", "CDATA", "http://openoffice.org/2000/drawing;);
-padd("xmlns:fo", "CDATA", "http://www.w3.org/1999/XSL/Format;);
-padd("xmlns:xlink", "CDATA", "http://www.w3.org/1999/xlink;);
-padd("xmlns:dc", "CDATA", "http://purl.org/dc/elements/1.1/;);
-padd("xmlns:meta", "CDATA", "http://openoffice.org/2000/meta;);
-padd("xmlns:number", "CDATA", "http://openoffice.org/2000/datastyle;);
-padd("xmlns:svg", "CDATA", "http://www.w3.org/2000/svg;);
-padd("xmlns:chart", "CDATA", "http://openoffice.org/2000/chart;);
-padd("xmlns:dr3d", "CDATA", "http://openoffice.org/2000/dr3d;);
-padd("xmlns:math", "CDATA", "http://www.w3.org/1998/Math/MathML;);
-padd("xmlns:form", "CDATA", "http://openoffice.org/2000/form;);
-padd("xmlns:script", "CDATA", "http://openoffice.org/2000/script;);
+mxList->addAttribute("office:class", sXML_CDATA, "text");
+mxList->addAttribute("office:version", sXML_CDATA, "0.9");
+
+mxList->addAttribute("xmlns:office", "CDATA", 
"http://openoffice.org/2000/office;);
+mxList->addAttribute("xmlns:style", "CDATA", 
"http://openoffice.org/2000/style;);
+mxList->addAttribute("xmlns:text", "CDATA", 
"http://openoffice.org/2000/text;);
+mxList->addAttribute("xmlns:table", "CDATA", 
"http://openoffice.org/2000/table;);
+mxList->addAttribute("xmlns:draw", "CDATA", 
"http://openoffice.org/2000/drawing;);
+mxList->addAttribute("xmlns:fo", "CDATA", 
"http://www.w3.org/1999/XSL/Format;);
+mxList->addAttribute("xmlns:xlink", "CDATA", 
"http://www.w3.org/1999/xlink;);
+mxList->addAttribute("xmlns:dc", "CDATA", 
"http://purl.org/dc/elements/1.1/;);
+mxList->addAttribute("xmlns:meta", "CDATA", 
"http://openoffice.org/2000/meta;);
+mxList->addAttribute("xmlns:number", "CDATA", 
"http://openoffice.org/2000/datastyle;);
+mxList->addAttribute("xmlns:svg", "CDATA", "http://www.w3.org/2000/svg;);
+mxList->addAttribute("xmlns:chart", "CDATA", 
"http://openoffice.org/2000/chart;);
+mxList->addAttribute("xmlns:dr3d", "CDATA", 
"http://openoffice.org/2000/dr3d;);
+mxList->addAttribute("xmlns:math", "CDATA", 
"http://www.w3.org/1998/Math/MathML;);
+mxList->addAttribute("xmlns:form", "CDATA", 
"http://openoffice.org/2000/form;);
+mxList->addAttribute("xmlns:script", "CDATA", 
"http://openoffice.org/2000/script;);
 
 rstartEl("office:document", mxList);
  

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-04 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hbox.cxx  |   12 ++--
 hwpfilter/source/hbox.h|3 -
 hwpfilter/source/hcode.cxx |   12 ++--
 hwpfilter/source/hcode.h   |2 
 hwpfilter/source/hwpreader.cxx |  116 -
 5 files changed, 72 insertions(+), 73 deletions(-)

New commits:
commit ae6591d8dc2c1a705a1cc4cb102ff1d8cbe9d311
Author: Mike Kaganski 
AuthorDate: Fri Mar 4 11:06:29 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 4 11:45:54 2022 +0100

Drop hconv and replace hstr2ucsstr with hstr2OUString

Change-Id: I0c336003aa3d2d55ada13e79746b6eaa5363077c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130955
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index f9c1542b7cab..c17f3f6f9742 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -543,7 +543,7 @@ enum
number has the value. ex) '1.2.1' has '1,2,1'
style has the value which starts from 1 according to the definition in 
hbox.h
  */
-hchar_string Outline::GetUnicode() const
+OUString Outline::GetUnicode() const
 {
 const hchar *p;
 hchar buffer[255];
@@ -571,14 +571,14 @@ hchar_string Outline::GetUnicode() const
 strcat(buf, cur_num_str);
 }
 str2hstr(buf, buffer);
-return hstr2ucsstr(buffer);
+return hstr2OUString(buffer);
 }
 case OLSTY_NUMSIG1:
 case OLSTY_NUMSIG2:
 case OLSTY_NUMSIG3:
 {
 getOutlineNumStr(shape, level, number[level], buffer);
-return hstr2ucsstr(buffer);
+return hstr2OUString(buffer);
 }
 case OLSTY_BULLET1:
 case OLSTY_BULLET2:
@@ -589,7 +589,7 @@ hchar_string Outline::GetUnicode() const
 p = GetOutlineStyleChars(shape);
 buffer[0] = p[level];
 buffer[1] = 0;
-return hstr2ucsstr(buffer);
+return hstr2OUString(buffer);
 }
 case OLSTY_USER:
 case OLSTY_BULUSER:
@@ -676,11 +676,11 @@ hchar_string Outline::GetUnicode() const
 buffer[l++] = deco[i][1];
 }
 buffer[l] = 0;
-return hstr2ucsstr(buffer);
+return hstr2OUString(buffer);
 }
 }
 }
-return hstr2ucsstr(buffer);
+return hstr2OUString(buffer);
 }
 
 
diff --git a/hwpfilter/source/hbox.h b/hwpfilter/source/hbox.h
index afc208f956e0..b3bdffa74911 100644
--- a/hwpfilter/source/hbox.h
+++ b/hwpfilter/source/hbox.h
@@ -25,6 +25,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 #include "hwplib.h"
@@ -969,7 +970,7 @@ class Outline: public HBox
 Outline();
 
 virtual bool Read(HWPFile ) override;
-hchar_string GetUnicode() const;
+OUString GetUnicode() const;
 };
 
 /* Bundle of spaces (30) */
diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index ccd77c2c2440..c8cc6c13b15e 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -1166,17 +1167,16 @@ hchar ksc5601_han_to_ucs2 (hchar input)
 return '?';
 }
 
-hchar_string hstr2ucsstr(hchar const* hstr)
+OUString hstr2OUString(hchar const* hstr)
 {
-hchar_string ret;
+OUStringBuffer ret;
+static_assert(sizeof(hchar) == sizeof(sal_Unicode));
 hchar dest[3];
 for( ; *hstr ; ){
 int const res = hcharconv(*hstr++, dest, UNICODE);
-for (int j = 0 ; j < res ; j++) {
-ret.push_back(dest[j]);
-}
+ret.append(reinterpret_cast(dest), res);
 }
-return ret;
+return ret.makeStringAndClear();
 }
 
 /**
diff --git a/hwpfilter/source/hcode.h b/hwpfilter/source/hcode.h
index 8520538a863c..df77061a1736 100644
--- a/hwpfilter/source/hcode.h
+++ b/hwpfilter/source/hcode.h
@@ -38,7 +38,7 @@ DLLEXPORT int hcharconv(hchar ch, hchar *dest, int codeType) ;
 DLLEXPORT int   kssm_hangul_to_ucs2(hchar ch, hchar *dest) ;
 DLLEXPORT hchar ksc5601_han_to_ucs2 (hchar);
 DLLEXPORT hchar ksc5601_sym_to_ucs2 (hchar);
-DLLEXPORT hchar_string hstr2ucsstr(hchar const* hstr);
+DLLEXPORT OUString hstr2OUString(hchar const* hstr);
 /**
  * 한컴스트링을 완성형스트링으로 변환한다.
  */
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 1e9cbffe588f..9397b827b6c4 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -40,7 +40,6 @@
 #include 
 
 // To be shorten source code by realking
-#define hconv(x)hstr2ucsstr(x).c_str()
 #define ascii(x)OUString::createFromAscii(x)
 #define rstartEl(x,y)   do { if (m_rxDocumentHandler.is()) 
m_rxDocumentHandler->startElement(x,y); } while(false)
 #define rendEl(x)   do { if 

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-04 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hwpreader.cxx |  259 -
 1 file changed, 129 insertions(+), 130 deletions(-)

New commits:
commit 9f33c20dff4c2d86e1befd176c9ef8ec498a7f47
Author: Mike Kaganski 
AuthorDate: Fri Mar 4 10:38:41 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 4 10:58:49 2022 +0100

Drop Double2Str

Change-Id: I8b8c415347fd2409c55fdd6707b4f280b7881eaf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130954
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 3e92ae57ab11..1e9cbffe588f 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -46,7 +46,6 @@
 #define rendEl(x)   do { if (m_rxDocumentHandler.is()) 
m_rxDocumentHandler->endElement(x); } while(false)
 #define rchars(x)   do { if (m_rxDocumentHandler.is()) 
m_rxDocumentHandler->characters(x); } while(false)
 #define padd(x,y,z) mxList->addAttribute(x,y,z)
-#define Double2Str(x)   OUString::number(x)
 #define WTI(x)  (static_cast(x) / 1800.) // unit => inch
 #define WTMM(x) (static_cast(x) / 1800. * 25.4)  // unit => mm
 #define WTSM(x) (static_cast((x) / 1800. * 2540))   // unit ==> 1/100 
mm
@@ -445,18 +444,18 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 padd( "draw:name", sXML_CDATA, "LineType" + 
OUString::number(hdo->index));
 padd( "draw:style", sXML_CDATA, "round");
 padd( "draw:dots1", sXML_CDATA, "1");
-padd( "draw:dots1-length", sXML_CDATA, Double2Str( 
LineStyle[prop->line_pstyle].dots1 * WTMM(prop->line_width) ) + "cm");
+padd( "draw:dots1-length", sXML_CDATA, OUString::number( 
LineStyle[prop->line_pstyle].dots1 * WTMM(prop->line_width) ) + "cm");
 if( prop->line_pstyle == 3 )
 {
 padd( "draw:dots2", sXML_CDATA, "1");
-padd( "draw:dots2-length", sXML_CDATA, Double2Str( 
LineStyle[prop->line_pstyle].dots2 * WTMM(prop->line_width) ) + "cm");
+padd( "draw:dots2-length", sXML_CDATA, OUString::number( 
LineStyle[prop->line_pstyle].dots2 * WTMM(prop->line_width) ) + "cm");
 }
 else if( prop->line_pstyle == 4 )
 {
 padd( "draw:dots2", sXML_CDATA, "2");
-padd( "draw:dots2-length", sXML_CDATA, Double2Str( 
LineStyle[prop->line_pstyle].dots2 * WTMM(prop->line_width)) + "cm");
+padd( "draw:dots2-length", sXML_CDATA, OUString::number( 
LineStyle[prop->line_pstyle].dots2 * WTMM(prop->line_width)) + "cm");
 }
-padd( "draw:distance", sXML_CDATA, Double2Str( 
LineStyle[prop->line_pstyle].distance * WTMM(prop->line_width)) + "cm");
+padd( "draw:distance", sXML_CDATA, OUString::number( 
LineStyle[prop->line_pstyle].distance * WTMM(prop->line_width)) + "cm");
 rstartEl( "draw:stroke-dash", mxList);
 mxList->clear();
 rendEl( "draw:stroke-dash" );
@@ -700,7 +699,7 @@ void HwpReader::makeStyles()
 for( i = 1 ; i < 40 ; i++)
 {
 padd("style:position", sXML_CDATA,
-Double2Str( WTI(1000 * i)) + "inch");
+OUString::number( WTI(1000 * i)) + "inch");
 rstartEl("style:tab-stop", mxList);
 mxList->clear();
 rendEl("style:tab-stop");
@@ -1332,7 +1331,7 @@ void HwpReader::parseCharShape(CharShape const * cshape)
 if (sspace != 0.)
 {
 padd("fo:letter-spacing", sXML_CDATA,
-Double2Str(sspace) + "pt");
+OUString::number(sspace) + "pt");
 }
 if (cshape->color[1] != 0)
 padd("fo:color", sXML_CDATA,
@@ -1383,19 +1382,19 @@ void HwpReader::parseParaShape(ParaShape const * pshape)
 {
 
 if (pshape->left_margin != 0)
-padd("fo:margin-left", sXML_CDATA, Double2Str
+padd("fo:margin-left", sXML_CDATA, OUString::number
 (WTI(pshape->left_margin )) + "inch");
 if (pshape->right_margin != 0)
-padd("fo:margin-right", sXML_CDATA, Double2Str
+padd("fo:margin-right", sXML_CDATA, OUString::number
 (WTI(pshape->right_margin)) + "inch");
 if (pshape->pspacing_prev != 0)
-padd("fo:margin-top", sXML_CDATA, Double2Str
+padd("fo:margin-top", sXML_CDATA, OUString::number
 (WTI(pshape->pspacing_prev)) + "inch");
 if (pshape->pspacing_next != 0)
-padd("fo:margin-bottom", sXML_CDATA, Double2Str
+padd("fo:margin-bottom", sXML_CDATA, OUString::number
 (WTI(pshape->pspacing_next)) + "inch");
 if (pshape->indent != 0)
-padd("fo:text-indent", sXML_CDATA, Double2Str
+padd("fo:text-indent", sXML_CDATA, OUString::number
 (WTI(pshape->indent)) + "inch");
 if (pshape->lspacing != 0)
 padd("fo:line-height", sXML_CDATA, OUString::number(pshape->lspacing) 
+ "%");
@@ -1470,7 +1469,7 @@ void 

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-04 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hcode.cxx |   10 -
 hwpfilter/source/hcode.h   |4 
 hwpfilter/source/hwpreader.cxx |  245 +++--
 hwpfilter/source/hwpreader.hxx |8 +
 4 files changed, 99 insertions(+), 168 deletions(-)

New commits:
commit 596e4970c1475346f5fb19052db4fc2e565d84fa
Author: Mike Kaganski 
AuthorDate: Fri Mar 4 10:22:16 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 4 09:20:33 2022 +0100

Drop Int2Str

Change-Id: I6e59e285c8148b381fc7670939ddf8d335f6b528
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130949
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index c8c31a14085d..ccd77c2c2440 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -1236,16 +1236,6 @@ hchar_string kstr2hstr(uchar const* src)
 }
 
 
-/**
- * Transfer integer to string following format
- */
-char* Int2Str(int value, const char *format, char *buf)
-{
-sprintf(buf,format,value);
-return buf;
-}
-
-
 /* Convert a combination of a color index value and a shade value to the color 
value of LibreOffice */
 char *hcolor2str(uchar color, uchar shade, char *buf, bool bIsChar)
 {
diff --git a/hwpfilter/source/hcode.h b/hwpfilter/source/hcode.h
index e560911b74c6..8520538a863c 100644
--- a/hwpfilter/source/hcode.h
+++ b/hwpfilter/source/hcode.h
@@ -60,10 +60,6 @@ DLLEXPORT ::std::string urltounix(const char *src);
 #ifdef _WIN32
 DLLEXPORT ::std::string urltowin(const char *src);
 #endif
-/**
- *  Transfer integer to string following format
- */
-DLLEXPORT char* Int2Str(int value, const char *format, char *buf);
 
 /**
  * color인덱스 값과 음영값을 조합하여 스타오피스의 color로 변환
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 205edf757c12..3e92ae57ab11 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -54,13 +54,13 @@
 // xmloff/xmlkyd.hxx
 constexpr OUStringLiteral sXML_CDATA = u"CDATA";
 
-#define STARTP  padd( "text:style-name", "CDATA", 
ascii(getPStyleName((para->GetParaShape()).index,buf))); \
+#define STARTP  padd( "text:style-name", "CDATA", 
getPStyleName((para->GetParaShape()).index)); \
 rstartEl( "text:p",mxList ); \
 mxList->clear(); \
 pstart = true
 #define STARTT \
 curr = para->GetCharShape(n > 0 ? n-1 : 0)->index; \
-padd( "text:style-name", "CDATA" , ascii( getTStyleName(curr, buf) ) ); \
+padd( "text:style-name", "CDATA" , getTStyleName(curr) ); \
 rstartEl( "text:span",mxList ); \
 mxList->clear(); \
 tstart = true
@@ -442,7 +442,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 
 if( prop->line_pstyle > 0 && prop->line_pstyle < 5 && prop->line_color 
<= 0xff)
 {
-padd( "draw:name", sXML_CDATA, ascii(Int2Str(hdo->index, 
"LineType%d", buf)));
+padd( "draw:name", sXML_CDATA, "LineType" + 
OUString::number(hdo->index));
 padd( "draw:style", sXML_CDATA, "round");
 padd( "draw:dots1", sXML_CDATA, "1");
 padd( "draw:dots1-length", sXML_CDATA, Double2Str( 
LineStyle[prop->line_pstyle].dots1 * WTMM(prop->line_width) ) + "cm");
@@ -523,7 +523,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 {
 if( prop->flag >> 18  & 0x01 )
 {
-padd( "draw:name", sXML_CDATA, ascii(Int2Str(hdo->index, 
"fillimage%d", buf)));
+padd( "draw:name", sXML_CDATA, "fillimage" + 
OUString::number(hdo->index));
 
 EmPicture *emp = nullptr;
 if (prop->pictype && strlen(prop->szPatternFile) > 3)
@@ -550,7 +550,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 /*  If there is a gradient, when a bitmap file is present, this is the first. 
*/
 else if( prop->flag >> 16  & 0x01 )   /* existence gradient */
 {
-padd( "draw:name", sXML_CDATA, ascii(Int2Str(hdo->index, 
"Grad%d", buf)));
+padd( "draw:name", sXML_CDATA, "Grad" + 
OUString::number(hdo->index));
 switch( prop->gstyle )
 {
 case 1 :
@@ -570,8 +570,8 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 padd( "draw:style", sXML_CDATA, "linear");
 break;
 }
-padd( "draw:cx", sXML_CDATA,ascii(Int2Str(prop->center_x, 
"%d%%", buf)));
-padd( "draw:cy", sXML_CDATA,ascii(Int2Str(prop->center_y, 
"%d%%", buf)));
+padd( "draw:cx", sXML_CDATA, OUString::number(prop->center_x) 
+ "%");
+padd( "draw:cy", sXML_CDATA, OUString::number(prop->center_y) 
+ "%");
 
 HWPInfo& hwpinfo = hwpfile.GetHWPInfo();
 int default_color = 0xff;
@@ -622,8 +622,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 if( prop->angle > 0 && ( 

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-03 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hcode.cxx |   58 +++--
 hwpfilter/source/hcode.h   |6 +++-
 hwpfilter/source/hwpreader.cxx |   12 ++--
 3 files changed, 20 insertions(+), 56 deletions(-)

New commits:
commit 176a9dfcce7c10d1c5fd3e091f10a1d57d309b24
Author: Mike Kaganski 
AuthorDate: Fri Mar 4 09:29:04 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Mar 4 08:23:41 2022 +0100

Use comphelper::Base64 in hwpfilter

Change-Id: Id5c0a3d33ccda517473c8cbf96cb6e7b86ade57d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130945
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index e901fbbb3a58..c8c31a14085d 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -23,10 +23,17 @@
  * Hanja johap code => ks code => unicode
  * Special johap code => ks code => unicode
  */
+
+#include 
+
 #include "precompile.h"
+#include 
+#include 
 #include 
+#include 
 #include 
 #include 
+
 #include 
 #include 
 #include 
@@ -1385,54 +1392,11 @@ char *hcolor2str(uchar color, uchar shade, char *buf, 
bool bIsChar)
 }
 #endif
 
-char* base64_encode_string( const uchar *buf, unsigned int len )
+OUString base64_encode_string( const uchar *buf, unsigned int len )
 {
-char basis_64[] =
-"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-char * out;
-int inPos  = 0;
-int outPos = 0;
-int c1, c2;
-unsigned int i;
-
-out=static_cast(malloc( (len*4/3)+8 ));
-
-/* Get three characters at a time and encode them. */
-for (i=0; i < len/3; ++i)
-{
-c1 = buf[inPos++] & 0xFF;
-c2 = buf[inPos++] & 0xFF;
-int c3 = buf[inPos++] & 0xFF;
-out[outPos++] = basis_64[(c1 & 0xFC) >> 2];
-out[outPos++] = basis_64[((c1 & 0x03) << 4) | ((c2 & 0xF0) >> 4)];
-out[outPos++] = basis_64[((c2 & 0x0F) << 2) | ((c3 & 0xC0) >> 6)];
-out[outPos++] = basis_64[c3 & 0x3F];
-}
-
-/* Encode the remaining one or two characters. */
-
-switch (len % 3)
-{
-case 0:
-break;
-case 1:
-c1 = buf[inPos] & 0xFF;
-out[outPos++] = basis_64[(c1 & 0xFC) >> 2];
-out[outPos++] = basis_64[((c1 & 0x03) << 4)];
-out[outPos++] = '=';
-out[outPos++] = '=';
-break;
-case 2:
-c1 = buf[inPos++] & 0xFF;
-c2 = buf[inPos] & 0xFF;
-out[outPos++] = basis_64[(c1 & 0xFC) >> 2];
-out[outPos++] = basis_64[((c1 & 0x03) << 4) | ((c2 & 0xF0) >> 4)];
-out[outPos++] = basis_64[((c2 & 0x0F) << 2)];
-out[outPos++] = '=';
-break;
-}
-out[outPos] = 0;
-return out;
+OStringBuffer aBuf;
+comphelper::Base64::encode(aBuf, 
comphelper::arrayToSequence(buf, len));
+return OUString::createFromAscii(aBuf);
 }
 
 double calcAngle(int x1, int y1, int x2, int y2)
diff --git a/hwpfilter/source/hcode.h b/hwpfilter/source/hcode.h
index 3fb2da528ef7..e560911b74c6 100644
--- a/hwpfilter/source/hcode.h
+++ b/hwpfilter/source/hcode.h
@@ -19,6 +19,10 @@
 
 #pragma once
 
+#include 
+
+#include 
+
 #include "hwplib.h"
 
 /**
@@ -66,7 +70,7 @@ DLLEXPORT char* Int2Str(int value, const char *format, char 
*buf);
  */
 DLLEXPORT char *hcolor2str(uchar color, uchar shade, char *buf, bool bIsChar = 
false);
 
-DLLEXPORT char *base64_encode_string( const uchar *buf, unsigned int len );
+DLLEXPORT OUString base64_encode_string( const uchar *buf, unsigned int len );
 DLLEXPORT double calcAngle(int x1, int y1, int x2, int y2);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index a8272d82746e..205edf757c12 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -542,8 +542,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 if (emp)
 {
 rstartEl("office:binary-data", mxList);
-std::shared_ptr 
pStr(base64_encode_string(emp->data.get(), emp->size), Free());
-rchars(ascii(pStr.get()));
+rchars(base64_encode_string(emp->data.get(), emp->size));
 rendEl("office:binary-data");
 }
 rendEl( "draw:fill-image");
@@ -1723,8 +1722,7 @@ void HwpReader::makePageStyle()
  if( hwpinfo.back_info.type == 2 ){
  rstartEl("office:binary-data", mxList);
  mxList->clear();
- std::shared_ptr 
pStr(base64_encode_string(reinterpret_cast(hwpinfo.back_info.data.data()), hwpinfo.back_info.size ), Free());
- rchars(ascii(pStr.get()));
+ rchars(base64_encode_string(reinterpret_cast(hwpinfo.back_info.data.data()), hwpinfo.back_info.size));
  rendEl("office:binary-data");

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-03 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hwpreader.cxx |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

New commits:
commit 4cbaaf21fe1c22b36dd72798cecfa59e73d0f8c3
Author: Mike Kaganski 
AuthorDate: Thu Mar 3 23:02:41 2022 +0300
Commit: Mike Kaganski 
CommitDate: Thu Mar 3 22:59:04 2022 +0100

Use 's std::hypot

Change-Id: I2f9db19dca795b6318cd88ca645020077520f5da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130943
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 6c285c664e23..a8272d82746e 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3943,8 +3943,6 @@ void HwpReader::makePicture(Picture * hbox)
 }
 }
 
-namespace { double DBL(int x) { return x * x; } }
-
 void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
 {
 int x = hbox->pgx;
@@ -4047,8 +4045,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, Picture * hbox)
 bIsRotate = true;
 }
 if( bIsRotate ){
-drawobj->extent.w = 
static_cast(sqrt(DBL(pt[1].x-pt[0].x) + DBL(pt[1].y-pt[0].y)));
-drawobj->extent.h = 
static_cast(sqrt(DBL(pt[2].x-pt[1].x) + DBL(pt[2].y-pt[1].y)));
+drawobj->extent.w = 
static_cast(std::hypot(pt[1].x-pt[0].x, pt[1].y-pt[0].y));
+drawobj->extent.h = 
static_cast(std::hypot(pt[2].x-pt[1].x, pt[2].y-pt[1].y));
 padd("draw:transform", sXML_CDATA, trans);
 }
 }


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-03 Thread Mike Kaganski (via logerrit)
 hwpfilter/source/hwpreader.cxx |   55 +++--
 1 file changed, 15 insertions(+), 40 deletions(-)

New commits:
commit be1076297b9b1191030cb4fc8c94cfae354630da
Author: Mike Kaganski 
AuthorDate: Thu Mar 3 22:52:23 2022 +0300
Commit: Mike Kaganski 
CommitDate: Thu Mar 3 22:46:12 2022 +0100

Drop some strcpy

Change-Id: I304f69147e570f08c743183c54cc5b759143550a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130942
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 6095360c1ec9..6c285c664e23 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -86,6 +86,10 @@ struct Free
 }
 };
 
+constexpr OUStringLiteral sBeginOfDoc(u"[\uBB38\uC11C\uC758 \uCC98\uC74C]");
+// U+BB38 HANGUL SYLLABLE MUN, U+C11C HANGUL SYLLABLE SEO,
+// U+C758 HANGUL SYLLABLE YI, U+CC98 HANGUL SYLLABLE CEO,
+// U+C74C HANGUL SYLLABLE EUM: "Begin of Document"
 }
 
 struct HwpReaderPrivate
@@ -1406,32 +1410,28 @@ void HwpReader::parseParaShape(ParaShape const * pshape)
 padd("fo:line-height", sXML_CDATA,
 ascii(Int2Str (pshape->lspacing, "%d%%", buf)));
 
-unsigned char set_align = 0;
+const char* align = nullptr;
 
 switch (static_cast(pshape->arrange_type))
 {
 case 1:
-strcpy(buf, "start");
-set_align = 1;
+align = "start";
 break;
 case 2:
-strcpy(buf, "end");
-set_align = 1;
+align = "end";
 break;
 case 3:
-strcpy(buf, "center");
-set_align = 1;
+align = "center";
 break;
 case 4:
 case 5:
 case 6:
-strcpy(buf, "justify");
-set_align = 1;
+align = "justify";
 break;
 }
 
-if (set_align)
-padd("fo:text-align", sXML_CDATA, ascii(buf));
+if (align)
+padd("fo:text-align", sXML_CDATA, ascii(align));
 
 if (pshape->outline)
 padd("fo:border", sXML_CDATA, "0.002cm solid #00");
@@ -2705,13 +2705,7 @@ void HwpReader::make_text_p0(HWPPara * para, bool 
bParaStart)
 }
 if( d->bFirstPara && d->bInBody )
 {
-strcpy(
-buf,
-"[\xEB\xAC\xB8\xEC\x84\x9C\xEC\x9D\x98 \xEC\xB2\x98\xEC\x9D\x8C]");
-// U+BB38 HANGUL SYLLABLE MUN, U+C11C HANGUL SYLLABLE SEO,
-// U+C758 HANGUL SYLLABLE YI, U+CC98 HANGUL SYLLABLE CEO,
-// U+C74C HANGUL SYLLABLE EUM: "Begin of Document"
-padd("text:name", sXML_CDATA, OUString(buf, strlen(buf), 
RTL_TEXTENCODING_UTF8));
+padd("text:name", sXML_CDATA, sBeginOfDoc);
 rstartEl("text:bookmark", mxList);
 mxList->clear();
 rendEl("text:bookmark");
@@ -2781,13 +2775,7 @@ void HwpReader::make_text_p1(HWPPara * para,bool 
bParaStart)
 if( d->bFirstPara && d->bInBody )
 {
 /* for HWP's Bookmark */
-strcpy(
-buf,
-"[\xEB\xAC\xB8\xEC\x84\x9C\xEC\x9D\x98 \xEC\xB2\x98\xEC\x9D\x8C]");
-// U+BB38 HANGUL SYLLABLE MUN, U+C11C HANGUL SYLLABLE SEO,
-// U+C758 HANGUL SYLLABLE YI, U+CC98 HANGUL SYLLABLE CEO,
-// U+C74C HANGUL SYLLABLE EUM: "Begin of Document"
-padd("text:name", sXML_CDATA, OUString(buf, strlen(buf), 
RTL_TEXTENCODING_UTF8));
+padd("text:name", sXML_CDATA, sBeginOfDoc);
 rstartEl("text:bookmark", mxList);
 mxList->clear();
 rendEl("text:bookmark");
@@ -2865,13 +2853,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool 
bParaStart)
 if ( !pstart ) {
 STARTP;
 }
-strcpy(
-buf,
-"[\xEB\xAC\xB8\xEC\x84\x9C\xEC\x9D\x98 \xEC\xB2\x98\xEC\x9D\x8C]");
-// U+BB38 HANGUL SYLLABLE MUN, U+C11C HANGUL SYLLABLE SEO,
-// U+C758 HANGUL SYLLABLE YI, U+CC98 HANGUL SYLLABLE CEO,
-// U+C74C HANGUL SYLLABLE EUM: "Begin of Document"
-padd("text:name", sXML_CDATA, OUString(buf, strlen(buf), 
RTL_TEXTENCODING_UTF8));
+padd("text:name", sXML_CDATA, sBeginOfDoc);
 rstartEl("text:bookmark", mxList);
 mxList->clear();
 rendEl("text:bookmark");
@@ -4730,14 +4712,7 @@ void HwpReader::parsePara(HWPPara * para)
 if( d->bFirstPara && d->bInBody )
 {
 /* for HWP's Bookmark */
-strcpy(
-buf,
-"[\xEB\xAC\xB8\xEC\x84\x9C\xEC\x9D\x98"
-" \xEC\xB2\x98\xEC\x9D\x8C]");
-// U+BB38 HANGUL SYLLABLE MUN, U+C11C HANGUL SYLLABLE SEO,
-// U+C758 HANGUL SYLLABLE YI, U+CC98 HANGUL SYLLABLE CEO,
-// U+C74C HANGUL SYLLABLE EUM: "Begin of Document"
-padd("text:name", sXML_CDATA, OUString(buf, strlen(buf), 
RTL_TEXTENCODING_UTF8));
+   

[Libreoffice-commits] core.git: hwpfilter/source

2022-03-03 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c2432d011ba64f69bd64c08fc860d0bcbc7b3569
Author: Caolán McNamara 
AuthorDate: Thu Mar 3 12:55:12 2022 +
Commit: Caolán McNamara 
CommitDate: Thu Mar 3 18:17:19 2022 +0100

ofz#45183 Null-dereference

Change-Id: Ida18ceac652f6be0b2bc23682600d2c338ee0f06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130927
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 5729f5ebecf3..6095360c1ec9 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -4541,7 +4541,7 @@ void HwpReader::makeHidden(Hidden * hbox)
 padd("text:string-value", sXML_CDATA, "");
 rstartEl("text:hidden-text", mxList);
 mxList->clear();
-HWPPara *para = hbox->plist.front().get();
+HWPPara *para = !hbox->plist.empty() ? hbox->plist.front().get() : nullptr;
 
 while (para)
 {


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-03 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 117864df3688ae66b30ef0634fb0045363c604dd
Author: Caolán McNamara 
AuthorDate: Wed Mar 2 20:15:56 2022 +
Commit: Caolán McNamara 
CommitDate: Thu Mar 3 16:18:32 2022 +0100

remove now redundant double()

Change-Id: I4be6a481b7e1043bfada6e19b95a37e863c27772
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130896
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index ff18d5099557..6209445f40c8 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -4065,8 +4065,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, Picture * hbox)
 bIsRotate = true;
 }
 if( bIsRotate ){
-drawobj->extent.w = 
static_cast(sqrt(double(DBL(pt[1].x-pt[0].x) + DBL(pt[1].y-pt[0].y;
-drawobj->extent.h = 
static_cast(sqrt(double(DBL(pt[2].x-pt[1].x) + DBL(pt[2].y-pt[1].y;
+drawobj->extent.w = 
static_cast(sqrt(DBL(pt[1].x-pt[0].x) + DBL(pt[1].y-pt[0].y)));
+drawobj->extent.h = 
static_cast(sqrt(DBL(pt[2].x-pt[1].x) + DBL(pt[2].y-pt[1].y)));
 padd("draw:transform", sXML_CDATA, trans);
 }
 }


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-02 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 3e94bd846ab02f3f0dac55e9646ac778d6b7f284
Author: Caolán McNamara 
AuthorDate: Wed Mar 2 10:29:06 2022 +
Commit: Caolán McNamara 
CommitDate: Wed Mar 2 14:30:59 2022 +0100

ofz: Integer-overflow

turn macro into a function and have it return a double

Change-Id: Ib410d8f9f53271f58e44f2c46382871051a4476b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130836
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 3469fa1defb2..ff18d5099557 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3961,8 +3961,8 @@ void HwpReader::makePicture(Picture * hbox)
 }
 }
 
+namespace { double DBL(int x) { return x * x; } }
 
-#define DBL(x)  ((x) * (x))
 void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
 {
 int x = hbox->pgx;
@@ -4065,8 +4065,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, Picture * hbox)
 bIsRotate = true;
 }
 if( bIsRotate ){
-drawobj->extent.w = 
static_cast(sqrt(double(DBL(pt[1].x-pt[0].x)+DBL(pt[1].y-pt[0].y;
-drawobj->extent.h = 
static_cast(sqrt(double(DBL(pt[2].x-pt[1].x)+DBL(pt[2].y-pt[1].y;
+drawobj->extent.w = 
static_cast(sqrt(double(DBL(pt[1].x-pt[0].x) + DBL(pt[1].y-pt[0].y;
+drawobj->extent.h = 
static_cast(sqrt(double(DBL(pt[2].x-pt[1].x) + DBL(pt[2].y-pt[1].y;
 padd("draw:transform", sXML_CDATA, trans);
 }
 }


[Libreoffice-commits] core.git: hwpfilter/source

2022-03-01 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpread.cxx |   18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

New commits:
commit 8b95df7d8d4c4b651e169c73508fcd86833229ea
Author: Caolán McNamara 
AuthorDate: Tue Mar 1 10:18:51 2022 +
Commit: Caolán McNamara 
CommitDate: Tue Mar 1 15:08:47 2022 +0100

ofz: don't register style if hbox load failed

Change-Id: I4d9d5d76f0c2385871003720e933ed1926f66c70
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130755
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 3c06515e563b..85dd89a32f88 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -236,7 +236,6 @@ bool TxtBox::Read(HWPFile & hwpf)
 hwpf.Read2b(, 1);
 hwpf.Read2b(_ch, 1);
 hwpf.Read2b(style.margin, 12);
-hwpf.AddFBoxStyle();
 hwpf.Read2b(_xs, 1);
 hwpf.Read2b(_ys, 1);
 hwpf.Read2b(_xs, 1);
@@ -365,7 +364,10 @@ bool TxtBox::Read(HWPFile & hwpf)
 else
 m_pTable = nullptr;
 
-return !hwpf.State();
+bSuccess = !hwpf.State();
+if (bSuccess)
+hwpf.AddFBoxStyle();
+return bSuccess;
 }
 
 namespace
@@ -509,12 +511,14 @@ bool Picture::Read(HWPFile & hwpf)
 style.boxtype = 'G';
 else
 style.boxtype = 'D';
-hwpf.AddFBoxStyle();
 
 // caption
 hwpf.ReadParaList(caption);
 
-return !hwpf.State();
+bool bSuccess = !hwpf.State();
+if (bSuccess)
+hwpf.AddFBoxStyle();
+return bSuccess;
 }
 
 // line(15)
@@ -551,7 +555,6 @@ bool Line::Read(HWPFile & hwpf)
 hwpf.Read2b(, 1);
 hwpf.Read2b(_ch, 1);
 hwpf.Read2b(style.margin, 12);
-hwpf.AddFBoxStyle();
 hwpf.Read2b(_xs, 1);
 hwpf.Read2b(_ys, 1);
 hwpf.Read2b(_xs, 1);
@@ -580,7 +583,10 @@ bool Line::Read(HWPFile & hwpf)
 hwpf.Read2b(, 1);
 style.xpos = width;
 
-return !hwpf.State();
+bool bSuccess = !hwpf.State();
+if (bSuccess)
+hwpf.AddFBoxStyle();
+return bSuccess;
 }
 
 // hidden(15)


[Libreoffice-commits] core.git: hwpfilter/source

2022-02-28 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit f5f3eaa63f24093453af08ad01967ae17f108af2
Author: Caolán McNamara 
AuthorDate: Mon Feb 28 11:35:50 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Feb 28 14:00:35 2022 +0100

cid#1501377 Dereference after null check

Change-Id: I9dceb5c33f62df16b43429ba502b0d12180fa403
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130694
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index b424820eead8..3469fa1defb2 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -2636,7 +2636,7 @@ void HwpReader::makeFStyle(FBoxStyle * fstyle)
 padd( "style:border-line-width-bottom", sXML_CDATA, "0.02mm 0.35mm 
0.02mm");
 padd("fo:border-bottom", sXML_CDATA,"0.039cm double #808080");
 }
-else if( fstyle->boxtype == 'G' )
+else if( fstyle->boxtype == 'G' && fstyle->cell )
 {
 if( fstyle->margin[1][0] || fstyle->margin[1][1] || 
fstyle->margin[1][2] || fstyle->margin[1][3] ){
  OUString clip = "rect(" +


[Libreoffice-commits] core.git: hwpfilter/source

2022-02-28 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/drawing.h   |   13 +
 hwpfilter/source/hwpfile.cxx |9 +++--
 hwpfilter/source/hwpfile.h   |2 ++
 hwpfilter/source/hwpread.cxx |2 +-
 4 files changed, 19 insertions(+), 7 deletions(-)

New commits:
commit a74a4236e4f4cc957123a9417c7da99b2699b242
Author: Caolán McNamara 
AuthorDate: Sun Feb 27 21:17:52 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Feb 28 09:47:52 2022 +0100

ofz#44991 keep paragraph's that failed to load until import is complete

to avoid dangling references to them

Change-Id: Ic8710f63a8cf6a6a665348c7c84bf0b43f0e2c83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130612
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/drawing.h b/hwpfilter/source/drawing.h
index c7526a4c591e..54d98bbf5262 100644
--- a/hwpfilter/source/drawing.h
+++ b/hwpfilter/source/drawing.h
@@ -315,7 +315,7 @@ static bool LoadCommonHeader(HWPDrawingObject * hdo, 
unsigned short * link_info)
 return hmem->skipBlock(size - common_size ) != 0;
 }
 
-static std::unique_ptr LoadDrawingObject(void)
+static std::unique_ptr LoadDrawingObject(HWPFile& hwpf)
 {
 HWPDrawingObject *prev = nullptr;
 std::unique_ptr hdo, head;
@@ -354,7 +354,7 @@ static std::unique_ptr 
LoadDrawingObject(void)
 }
 if (link_info & HDOFILE_HAS_CHILD)
 {
-hdo->child = LoadDrawingObject();
+hdo->child = LoadDrawingObject(hwpf);
 if (hdo->child == nullptr)
 {
 goto error;
@@ -383,6 +383,11 @@ error:
 {
 hdo->type = HWPDO_RECT;
 }
+if (hdo->property.pPara)
+{
+hwpf.move_to_failed(std::unique_ptr(hdo->property.pPara));
+hdo->property.pPara = nullptr;
+}
 HWPDOFunc(hdo.get(), OBJFUNC_FREE, nullptr, 0);
 hdo.reset();
 
@@ -396,7 +401,7 @@ error:
 }
 
 
-static bool LoadDrawingObjectBlock(Picture * pic)
+static bool LoadDrawingObjectBlock(Picture * pic, HWPFile& hwpf)
 {
 int size;
 if (!hmem->read4b(size))
@@ -422,7 +427,7 @@ static bool LoadDrawingObjectBlock(Picture * pic)
 !hmem->skipBlock(size - HDOFILE_HEADER_SIZE))
 return false;
 
-pic->picinfo.picdraw.hdo = LoadDrawingObject().release();
+pic->picinfo.picdraw.hdo = LoadDrawingObject(hwpf).release();
 if (pic->picinfo.picdraw.hdo == nullptr)
 return false;
 return true;
diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index f9d74e896d0d..58d6c4849d91 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -238,7 +238,7 @@ void HWPFile::ReadParaList(std::vector < HWPPara* > )
 aplist.push_back(spNode.release());
 spNode.reset( new HWPPara );
 }
-pfailedlist.push_back(std::move(spNode));
+move_to_failed(std::move(spNode));
 }
 
 void HWPFile::ReadParaList(std::vector< std::unique_ptr > , 
unsigned char flag)
@@ -272,7 +272,12 @@ void HWPFile::ReadParaList(std::vector< 
std::unique_ptr > , unsi
 aplist.push_back(std::move(spNode));
 spNode.reset( new HWPPara );
 }
-pfailedlist.push_back(std::move(spNode));
+move_to_failed(std::move(spNode));
+}
+
+void HWPFile::move_to_failed(std::unique_ptr xPara)
+{
+pfailedlist.push_back(std::move(xPara));
 }
 
 void HWPFile::TagsRead()
diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h
index 5c9aab9828b1..72d22a5aeb95 100644
--- a/hwpfilter/source/hwpfile.h
+++ b/hwpfilter/source/hwpfile.h
@@ -252,6 +252,8 @@ class DLLEXPORT HWPFile
 }
 void pop_hpara_type() { element_import_stack.pop_back(); }
 
+void move_to_failed(std::unique_ptr rPara);
+
 private:
 int compareCharShape(CharShape const *shape);
 int compareParaShape(ParaShape const *shape);
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 9cffef46d17e..3c06515e563b 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -492,7 +492,7 @@ bool Picture::Read(HWPFile & hwpf)
 if (pictype == PICTYPE_DRAW)
 {
 auto xGuard(std::make_unique(follow.data(), 
follow_block_size));
-LoadDrawingObjectBlock(this);
+LoadDrawingObjectBlock(this, hwpf);
 style.cell = picinfo.picdraw.hdo;
 xGuard.reset();
 }


[Libreoffice-commits] core.git: hwpfilter/source

2022-02-27 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit d71aa209aec6adbd273497e240ae447e81ed9c05
Author: Caolán McNamara 
AuthorDate: Sun Feb 27 17:29:38 2022 +
Commit: Caolán McNamara 
CommitDate: Sun Feb 27 20:59:21 2022 +0100

ofz#45090 Null-dereference READ

Change-Id: I74c1c0d1a090dbd763336fec845e29d6cc0065f4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130651
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index f31f1e779e60..b424820eead8 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -2296,7 +2296,7 @@ void HwpReader::makeCaptionStyle(FBoxStyle * fstyle)
 padd("style:vertical-rel", sXML_CDATA, "paragraph");
 padd("style:horizontal-pos", sXML_CDATA, "from-left");
 padd("style:horizontal-rel", sXML_CDATA, "paragraph");
-if( fstyle->boxtype == 'G' )
+if (fstyle->boxtype == 'G' && fstyle->cell)
 {
 char *cell = static_cast(fstyle->cell);
 padd("draw:luminance", sXML_CDATA,
@@ -2310,7 +2310,7 @@ void HwpReader::makeCaptionStyle(FBoxStyle * fstyle)
 else if( cell[2] == 2 )
 padd("draw:color-mode", sXML_CDATA, "mono");
 }
-else
+else if (fstyle->cell)
 {
 Cell *cell = static_cast(fstyle->cell);
 if(cell->linetype[0] == cell->linetype[1] &&


[Libreoffice-commits] core.git: hwpfilter/source

2022-02-27 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c97a3592c78ce276a353f95ce68c70a8a39174a0
Author: Caolán McNamara 
AuthorDate: Sun Feb 27 15:00:38 2022 +
Commit: Caolán McNamara 
CommitDate: Sun Feb 27 18:04:14 2022 +0100

ofz#45090 Null-dereference

Change-Id: I53ec35a8fe19511429004c8a94aee1bfadb55a86
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130648
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index ef40fa2ddb67..f31f1e779e60 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -2521,7 +2521,7 @@ void HwpReader::makeFStyle(FBoxStyle * fstyle)
 padd("style:horizontal-rel", sXML_CDATA, "page-content");
 }
 }
-if( fstyle->boxtype == 'X' || fstyle->boxtype == 'B' )
+if (fstyle->cell && (fstyle->boxtype == 'X' || fstyle->boxtype == 'B'))
 {
 Cell *cell = static_cast(fstyle->cell);
 if(cell->linetype[0] == cell->linetype[1] &&


[Libreoffice-commits] core.git: hwpfilter/source

2022-02-27 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |   14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

New commits:
commit 4ca4c5ea49ddb1b00127c5ea8066215533b96c63
Author: Caolán McNamara 
AuthorDate: Sat Feb 26 20:04:15 2022 +
Commit: Caolán McNamara 
CommitDate: Sun Feb 27 12:42:44 2022 +0100

ofz#44991 keep within legal ArrowShape range

Change-Id: I6bf70f27a66ba9b355a3f7ae0c68a696a7284871
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130611
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index c8c09e922d29..ef40fa2ddb67 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -461,7 +461,9 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 if( hdo->type == HWPDO_LINE || hdo->type == HWPDO_ARC || hdo->type == 
HWPDO_FREEFORM ||
 hdo->type == HWPDO_ADVANCED_ARC )
 {
-if( prop->line_tstyle && !ArrowShape[prop->line_tstyle].bMade  )
+if( prop->line_tstyle > 0 &&
+o3tl::make_unsigned(prop->line_tstyle) < std::size(ArrowShape) 
&&
+!ArrowShape[prop->line_tstyle].bMade  )
 {
 ArrowShape[prop->line_tstyle].bMade = true;
 padd("draw:name", sXML_CDATA,
@@ -485,7 +487,9 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 mxList->clear();
 rendEl("draw:marker");
 }
-if( prop->line_hstyle && !ArrowShape[prop->line_hstyle].bMade)
+if (prop->line_hstyle > 0 &&
+o3tl::make_unsigned(prop->line_hstyle) < std::size(ArrowShape) 
&&
+!ArrowShape[prop->line_hstyle].bMade)
 {
 ArrowShape[prop->line_hstyle].bMade = true;
 padd("draw:name", sXML_CDATA,
@@ -2052,7 +2056,8 @@ void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, 
FBoxStyle * fstyle)
 hdo->type == HWPDO_FREEFORM || hdo->type == HWPDO_ADVANCED_ARC )
 {
 
-if( hdo->property.line_tstyle > 0 )
+if( hdo->property.line_tstyle > 0 &&
+o3tl::make_unsigned(hdo->property.line_tstyle) < 
std::size(ArrowShape) )
 {
 padd("draw:marker-start", sXML_CDATA,
 ascii(ArrowShape[hdo->property.line_tstyle].name) );
@@ -2073,7 +2078,8 @@ void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, 
FBoxStyle * fstyle)
   Double2Str( WTMM(hdo->property.line_width * 7)) 
+ "mm");
 }
 
-if( hdo->property.line_hstyle > 0 )
+if( hdo->property.line_hstyle > 0 &&
+o3tl::make_unsigned(hdo->property.line_hstyle) < 
std::size(ArrowShape) )
 {
 padd("draw:marker-end", sXML_CDATA,
 ascii(ArrowShape[hdo->property.line_hstyle].name) );


[Libreoffice-commits] core.git: hwpfilter/source

2022-02-27 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hcode.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 846e02fbac63eebab33819c3a8a1460d4df07279
Author: Caolán McNamara 
AuthorDate: Sat Feb 26 19:52:29 2022 +
Commit: Caolán McNamara 
CommitDate: Sun Feb 27 12:42:23 2022 +0100

ofz#44991 don't skip over terminator

Change-Id: Ibc942705a788db60c104d00916a45d595596285e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130610
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index 514e594a2c49..e901fbbb3a58 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -1221,6 +1221,8 @@ hchar_string kstr2hstr(uchar const* src)
 {
 ret.push_back(src[i] << 8 | src[i+1]);
 i++;
+if (src[i] == '\0')
+break;
 }
 }
 return ret;


[Libreoffice-commits] core.git: hwpfilter/source

2022-02-26 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hbox.cxx |7 +++
 hwpfilter/source/hbox.h   |2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

New commits:
commit f6a9910623cdeb30b7c0a8dc712153a11658e43d
Author: Caolán McNamara 
AuthorDate: Sat Feb 26 16:10:09 2022 +
Commit: Caolán McNamara 
CommitDate: Sat Feb 26 21:05:49 2022 +0100

ofz#44991 Use-of-uninitialized-value

Change-Id: I0e3bcce489b665bac3e470e743394935a2ba3a18
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130601
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index 6bbf6d22448b..f9c1542b7cab 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -107,6 +107,8 @@ DateFormat::DateFormat()
 // date code(8)
 DateCode::DateCode()
 : HBox(CH_DATE_CODE)
+, format{0}
+, date{0}
 , dummy(0)
 , key(0)
 {
@@ -344,6 +346,7 @@ TxtBox::~TxtBox()
 
 Picture::Picture()
 : FBox(CH_PICTURE)
+, reserved{0}
 , dummy(0)
 , follow_block_size(0)
 , dummy1(0)
@@ -352,6 +355,10 @@ Picture::Picture()
 , cap_pos(0)
 , num(0)
 , pictype(0)
+, skip{0}
+, scale{0}
+, picinfo{}
+, reserved3{0}
 , ishyper(false)
 {
 }
diff --git a/hwpfilter/source/hbox.h b/hwpfilter/source/hbox.h
index 869fedd8ba90..afc208f956e0 100644
--- a/hwpfilter/source/hbox.h
+++ b/hwpfilter/source/hbox.h
@@ -617,7 +617,7 @@ struct Picture: public FBox
  * Ratio of magnification or reduction.
  */
 hunit scale[2];
-PicDefpicinfo = {};
+PicDefpicinfo;
 char  reserved3[9];
 
 std::vector> caption;


[Libreoffice-commits] core.git: hwpfilter/source

2022-02-23 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |   54 +
 hwpfilter/source/hwpreader.hxx |2 +
 2 files changed, 30 insertions(+), 26 deletions(-)

New commits:
commit e1f5044b43dbe13e0c5a8383ec3f84b4c2c44ddd
Author: Caolán McNamara 
AuthorDate: Tue Feb 22 15:39:35 2022 +
Commit: Caolán McNamara 
CommitDate: Wed Feb 23 11:20:44 2022 +0100

we should be testing more in the hwpfuzzer

Change-Id: I742efee39496d098677fa251727494bb741f627d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130357
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index d402e4250e92..923d81f32cc8 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -130,39 +130,17 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool 
TestImportHWP(SvStream )
 stream->addData(aData, static_cast(nRead));
 }
 
-HWPFile hwpfile;
-if (hwpfile.ReadHwpFile(std::move(stream)))
-return false;
+rtl::Reference hwpreader(new HwpReader);
+return hwpreader->importHStream(std::move(stream));
 }
 catch (...)
 {
-return false;
 }
-return true;
+return false;
 }
 
-sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor)
+bool HwpReader::importHStream(std::unique_ptr stream)
 {
-utl::MediaDescriptor aDescriptor(rDescriptor);
-aDescriptor.addInputStream();
-
-Reference< XInputStream > xInputStream(
-aDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM], UNO_QUERY_THROW);
-
-std::unique_ptr stream(new HStream);
-Sequence < sal_Int8 > aBuffer;
-sal_Int32 nRead, nTotal = 0;
-while( true )
-{
-nRead = xInputStream->readBytes(aBuffer, 32768);
-if( nRead == 0 )
-break;
-stream->addData( reinterpret_cast(aBuffer.getConstArray()), nRead );
-nTotal += nRead;
-}
-
-if( nTotal == 0 ) return false;
-
 if (hwpfile.ReadHwpFile(std::move(stream)))
   return false;
 
@@ -205,6 +183,30 @@ sal_Bool HwpReader::filter(const Sequence< PropertyValue 
>& rDescriptor)
 return true;
 }
 
+sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor)
+{
+utl::MediaDescriptor aDescriptor(rDescriptor);
+aDescriptor.addInputStream();
+
+Reference< XInputStream > xInputStream(
+aDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM], UNO_QUERY_THROW);
+
+std::unique_ptr stream(new HStream);
+Sequence < sal_Int8 > aBuffer;
+sal_Int32 nRead, nTotal = 0;
+while( true )
+{
+nRead = xInputStream->readBytes(aBuffer, 32768);
+if( nRead == 0 )
+break;
+stream->addData( reinterpret_cast(aBuffer.getConstArray()), nRead );
+nTotal += nRead;
+}
+
+if( nTotal == 0 ) return false;
+
+return importHStream(std::move(stream));
+}
 
 /**
  * make office:body
diff --git a/hwpfilter/source/hwpreader.hxx b/hwpfilter/source/hwpreader.hxx
index 91021a326186..309f454e6ffe 100644
--- a/hwpfilter/source/hwpreader.hxx
+++ b/hwpfilter/source/hwpreader.hxx
@@ -88,6 +88,8 @@ public:
 {
 m_rxDocumentHandler = xHandler;
 }
+
+bool importHStream(std::unique_ptr stream);
 private:
 Reference< XDocumentHandler > m_rxDocumentHandler;
 rtl::Reference mxList;


[Libreoffice-commits] core.git: hwpfilter/source

2022-02-23 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpfile.cxx |2 ++
 hwpfilter/source/hwpfile.h   |4 
 2 files changed, 6 insertions(+)

New commits:
commit 7e482815b4a719fa4d04f0013c96d8a8063bad21
Author: Caolán McNamara 
AuthorDate: Tue Feb 22 16:09:53 2022 +
Commit: Caolán McNamara 
CommitDate: Wed Feb 23 09:32:30 2022 +0100

keep paragraph's that failed to load until import is complete

LIBREOFFICE-509JU93T

Change-Id: I526edb182fed4fa023cce58e78a650a7c2046ed3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130363
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index 528f00a12f5f..f9d74e896d0d 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -238,6 +238,7 @@ void HWPFile::ReadParaList(std::vector < HWPPara* > )
 aplist.push_back(spNode.release());
 spNode.reset( new HWPPara );
 }
+pfailedlist.push_back(std::move(spNode));
 }
 
 void HWPFile::ReadParaList(std::vector< std::unique_ptr > , 
unsigned char flag)
@@ -271,6 +272,7 @@ void HWPFile::ReadParaList(std::vector< 
std::unique_ptr > , unsi
 aplist.push_back(std::move(spNode));
 spNode.reset( new HWPPara );
 }
+pfailedlist.push_back(std::move(spNode));
 }
 
 void HWPFile::TagsRead()
diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h
index 7cb693d948ca..5c9aab9828b1 100644
--- a/hwpfilter/source/hwpfile.h
+++ b/hwpfilter/source/hwpfile.h
@@ -279,6 +279,10 @@ class DLLEXPORT HWPFile
 std::vector> columnlist;
 // paragraph list
 std::vector> plist;
+// keep paragraph's that failed to load until
+// import is complete to avoid dangling references
+// elsewhere
+std::vector> pfailedlist;
 // embedded picture list(tag data)
 std::vector> emblist;
 std::vector> hyperlist;


[Libreoffice-commits] core.git: hwpfilter/source

2022-02-23 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpfile.cxx |5 -
 hwpfilter/source/hwpfile.h   |3 ---
 hwpfilter/source/hwpread.cxx |3 ---
 3 files changed, 11 deletions(-)

New commits:
commit 445c38d0ea247e48055d770df2fe9fffe5a80e0e
Author: Caolán McNamara 
AuthorDate: Tue Feb 22 15:56:52 2022 +
Commit: Caolán McNamara 
CommitDate: Wed Feb 23 09:32:11 2022 +0100

blist is written to but not read from and storing pointers has no sideeffect

Change-Id: I45221eda3d8536df75c4471888f35fb1b89e0a54
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130358
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index 5f32a38c0633..528f00a12f5f 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -450,11 +450,6 @@ EmPicture *HWPFile::GetEmPictureByName(char * name)
 return nullptr;
 }
 
-void HWPFile::AddBox(FBox * box)
-{
-blist.push_back(box);
-}
-
 ParaShape *HWPFile::getParaShape(int index)
 {
 if (index < 0 || o3tl::make_unsigned(index) >= pslist.size())
diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h
index 867a05fb7418..7cb693d948ca 100644
--- a/hwpfilter/source/hwpfile.h
+++ b/hwpfilter/source/hwpfile.h
@@ -202,7 +202,6 @@ class DLLEXPORT HWPFile
 A3Paper = 8
 };
 
-void AddBox(FBox *);
 void AddPage(){ m_nCurrentPage++;}
 void AddColumnInfo();
 void SetColumnDef(std::shared_ptr const &);
@@ -280,8 +279,6 @@ class DLLEXPORT HWPFile
 std::vector> columnlist;
 // paragraph list
 std::vector> plist;
-// floating box list
-std::vector blist;
 // embedded picture list(tag data)
 std::vector> emblist;
 std::vector> hyperlist;
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 8e4a96c726d0..9cffef46d17e 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -221,7 +221,6 @@ bool TxtBox::Read(HWPFile & hwpf)
 if (hh != dummy || CH_TEXT_BOX != dummy) {
 return hwpf.SetState(HWP_InvalidFileFormat);
 }
-hwpf.AddBox(this);
 hwpf.Read2b(_len, 1);
 hwpf.Read2b(, 1);
 unsigned short next;
@@ -400,7 +399,6 @@ bool Picture::Read(HWPFile & hwpf)
 if (hh != dummy || CH_PICTURE != dummy) {
 return hwpf.SetState(HWP_InvalidFileFormat);
 }
-hwpf.AddBox(this);
 
 hwpf.Read4b(follow_block_size);
 
@@ -541,7 +539,6 @@ bool Line::Read(HWPFile & hwpf)
 if (hh != dummy || CH_LINE != dummy) {
 return hwpf.SetState(HWP_InvalidFileFormat);
 }
-hwpf.AddBox(this);
 
 style.boxnum = fboxnum++;
 zorder = zindex++;


[Libreoffice-commits] core.git: hwpfilter/source

2022-01-29 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpreader.cxx |   64 +
 1 file changed, 15 insertions(+), 49 deletions(-)

New commits:
commit 8c5619b0272a67530760573993814fe7968a6c97
Author: Caolán McNamara 
AuthorDate: Fri Jan 28 15:02:54 2022 +
Commit: Caolán McNamara 
CommitDate: Sat Jan 29 14:31:01 2022 +0100

avoid dangling tmp files in hwp import

if there is embedded data use office-binary-data to transport it
instead of a temp file

https: //issues.oasis-open.org/browse/OFFICE-3933
Change-Id: Ia1cebf0770c99210df09f03dbb507451d9cf7764
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129114
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index e26cbb26143a..d402e4250e92 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -514,62 +514,28 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
 if( prop->flag >> 18  & 0x01 )
 {
 padd( "draw:name", sXML_CDATA, ascii(Int2Str(hdo->index, 
"fillimage%d", buf)));
-if( !prop->pictype )
+
+EmPicture *emp = nullptr;
+if (prop->pictype && strlen(prop->szPatternFile) > 3)
+emp = hwpfile.GetEmPictureByName(prop->szPatternFile);
+if (!emp)
 {
 padd( "xlink:href", sXML_CDATA,
 fromHcharStringToOUString(hstr2ucsstr(kstr2hstr( 
reinterpret_cast(urltounix(prop->szPatternFile).c_str())).c_str(;
+padd( "xlink:type", sXML_CDATA, "simple");
+padd( "xlink:show", sXML_CDATA, "embed");
+padd( "xlink:actuate", sXML_CDATA, "onLoad");
 }
-else
-{
-EmPicture *emp = nullptr;
-if ( strlen( prop->szPatternFile ) > 3)
-emp = hwpfile.GetEmPictureByName(prop->szPatternFile);
-if( emp )
-{
-char filename[128+17+9];
-char dirname[128];
-int fd;
-#ifdef _WIN32
-GetTempPathA(sizeof(dirname), dirname);
-sprintf(filename, "%s%s",dirname, emp->name);
-if( (fd = open( filename , _O_CREAT | _O_WRONLY | 
_O_BINARY , 0666)) >= 0 )
-#else
-strcpy(dirname, "/tmp/");
-sprintf(filename, "%s%s", dirname, emp->name);
-if( (fd = open( filename , O_CREAT | O_WRONLY , 0666)) 
>= 0 )
-#endif
-{
-size_t nWritten = write(fd, emp->data.get(), 
emp->size);
-OSL_VERIFY(nWritten == emp->size);
-close(fd);
-}
-#ifdef _WIN32
-int j;
-for(j = 0 ; j < static_cast(strlen( dirname )) ; 
j++)
-{
-if( dirname[j] == '\\' ) buf[j] = '/';
-else buf[j] = dirname[j];
-}
-buf[j] = '\0';
-sprintf(filename, "file:///%s%s",buf, emp->name );
-#else
-sprintf(filename, "file://%s%s",dirname, emp->name );
-#endif
-padd( "xlink:href", sXML_CDATA, ascii(filename));
-}
-else
-{
-padd( "xlink:href", sXML_CDATA,
-fromHcharStringToOUString(hstr2ucsstr(kstr2hstr( 
reinterpret_cast(urltounix(prop->szPatternFile).c_str())).c_str(;
-}
-
-}
-padd( "xlink:type", sXML_CDATA, "simple");
-padd( "xlink:show", sXML_CDATA, "embed");
-padd( "xlink:actuate", sXML_CDATA, "onLoad");
 
 rstartEl( "draw:fill-image", mxList);
 mxList->clear();
+if (emp)
+{
+rstartEl("office:binary-data", mxList);
+std::shared_ptr 
pStr(base64_encode_string(emp->data.get(), emp->size), Free());
+rchars(ascii(pStr.get()));
+rendEl("office:binary-data");
+}
 rendEl( "draw:fill-image");
 }
 /*  If there is a gradient, when a bitmap file is present, this is the first. 
*/


[Libreoffice-commits] core.git: hwpfilter/source

2022-01-28 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/htags.cxx |   26 +++---
 1 file changed, 11 insertions(+), 15 deletions(-)

New commits:
commit 231f827fabe0b4361c6e3e3245e7bf25a61dff44
Author: Caolán McNamara 
AuthorDate: Fri Jan 28 11:34:23 2022 +
Commit: Caolán McNamara 
CommitDate: Fri Jan 28 20:18:06 2022 +0100

use our own tempfile mechanism

Change-Id: Ie7853ea8bd083d1056872cfad4323ff6cede235f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129097
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx
index b8cafcf38675..4644d286d75c 100644
--- a/hwpfilter/source/htags.cxx
+++ b/hwpfilter/source/htags.cxx
@@ -19,6 +19,9 @@
 
 #include "precompile.h"
 
+#include 
+#include 
+
 #include 
 
 #include "hwplib.h"
@@ -108,27 +111,20 @@ void OlePicture::Read(HWPFile & hwpf)
   delete [] data;
   return;
 }
-FILE *fp;
-char tname[200];
-wchar_t wtname[200];
-tmpnam(tname);
-if (nullptr == (fp = fopen(tname, "wb")))
-{
- delete [] data;
- return;
-}
-fwrite(data, size, 1, fp);
+
+utl::TempFile aTempFile;
+aTempFile.EnableKillingFile();
+
+SvFileStream aOutputStream(aTempFile.GetURL(), StreamMode::WRITE);
+aOutputStream.WriteBytes(data, size);
 delete [] data;
-fclose(fp);
-MultiByteToWideChar(CP_ACP, 0, tname, -1, wtname, 200);
-if( StgOpenStorage(wtname, nullptr,
+aOutputStream.Close();
+if( StgOpenStorage(o3tl::toW(aTempFile.GetFileName().getStr()), nullptr,
 STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED,
 nullptr, 0, ) != S_OK ) {
  pis = nullptr;
- unlink(tname);
  return;
 }
-unlink(tname);
 #else
 hwpf.SkipBlock(size);
 #endif


[Libreoffice-commits] core.git: hwpfilter/source

2022-01-13 Thread Stephan Bergmann (via logerrit)
 hwpfilter/source/hstyle.cxx |   26 --
 hwpfilter/source/hstyle.h   |5 -
 2 files changed, 16 insertions(+), 15 deletions(-)

New commits:
commit 9780be6c05ece20d292035f6aba50dab34a8b024
Author: Stephan Bergmann 
AuthorDate: Thu Jan 13 12:11:43 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Jan 13 14:29:12 2022 +0100

Make HWPStyle::style type-safe

Change-Id: I3a8dcf497a236d12eedff9e7b5943e14747cb9bb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128374
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/hwpfilter/source/hstyle.cxx b/hwpfilter/source/hstyle.cxx
index fbbe30025d0a..23ae86c68538 100644
--- a/hwpfilter/source/hstyle.cxx
+++ b/hwpfilter/source/hstyle.cxx
@@ -30,9 +30,7 @@ enum
 MAXSTYLENAME = 20
 };
 
-#define DATA static_cast(style)
-
-namespace
+namespace hwpfilter
 {
 struct StyleData
 {
@@ -52,7 +50,7 @@ HWPStyle::HWPStyle()
 
 HWPStyle::~HWPStyle()
 {
-delete[] DATA;
+delete[] style;
 nstyles = 0;
 }
 
@@ -60,7 +58,7 @@ char* HWPStyle::GetName(int n) const
 {
 if (n < 0 || n >= nstyles)
 return nullptr;
-return DATA[n].name;
+return style[n].name;
 }
 
 void HWPStyle::SetName(int n, char const* name)
@@ -74,7 +72,7 @@ void HWPStyle::SetName(int n, char const* name)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wstringop-truncation"
 #endif
-auto const p = DATA[n].name;
+auto const p = style[n].name;
 strncpy(p, name, MAXSTYLENAME);
 p[MAXSTYLENAME] = '\0'; // just in case, even though the array is 
zero-initialized
 #if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 11) && !defined __clang__
@@ -82,14 +80,14 @@ void HWPStyle::SetName(int n, char const* name)
 #endif
 }
 else
-DATA[n].name[0] = 0;
+style[n].name[0] = 0;
 }
 
 CharShape* HWPStyle::GetCharShape(int n) const
 {
 if (n < 0 || n >= nstyles)
 return nullptr;
-return [n].cshape;
+return [n].cshape;
 }
 
 void HWPStyle::SetCharShape(int n, CharShape const* cshapep)
@@ -97,9 +95,9 @@ void HWPStyle::SetCharShape(int n, CharShape const* cshapep)
 if (n >= 0 && n < nstyles)
 {
 if (cshapep)
-DATA[n].cshape = *cshapep;
+style[n].cshape = *cshapep;
 else
-memset([n].cshape, 0, sizeof(CharShape));
+memset([n].cshape, 0, sizeof(CharShape));
 }
 }
 
@@ -107,7 +105,7 @@ ParaShape* HWPStyle::GetParaShape(int n) const
 {
 if (n < 0 || n >= nstyles)
 return nullptr;
-return [n].pshape;
+return [n].pshape;
 }
 
 void HWPStyle::SetParaShape(int n, ParaShape const* pshapep)
@@ -115,9 +113,9 @@ void HWPStyle::SetParaShape(int n, ParaShape const* pshapep)
 if (n >= 0 && n < nstyles)
 {
 if (pshapep)
-DATA[n].pshape = *pshapep;
+style[n].pshape = *pshapep;
 else
-DATA[n].pshape = ParaShape();
+style[n].pshape = ParaShape();
 }
 }
 
@@ -127,7 +125,7 @@ void HWPStyle::Read(HWPFile& hwpf)
 ParaShape pshape;
 
 hwpf.Read2b(, 1);
-style = ::comphelper::newArray_null(nstyles);
+style = ::comphelper::newArray_null(nstyles);
 if (!style)
 return;
 
diff --git a/hwpfilter/source/hstyle.h b/hwpfilter/source/hstyle.h
index 66fa09634afb..851bd8d4d164 100644
--- a/hwpfilter/source/hstyle.h
+++ b/hwpfilter/source/hstyle.h
@@ -25,13 +25,16 @@
 
 #include "hwplib.h"
 #include "hinfo.h"
+
+namespace hwpfilter { struct StyleData; }
+
 /**
  * @short Using for global style object like "Standard"
  */
 class DLLEXPORT HWPStyle
 {
 short nstyles;
-void *style;
+hwpfilter::StyleData *style;
 public:
 HWPStyle( void );
 ~HWPStyle( void );


[Libreoffice-commits] core.git: hwpfilter/source i18nlangtag/source idlc/source idl/source include/basegfx include/canvas include/comphelper include/cppuhelper include/salhelper

2021-12-21 Thread Noel Grandin (via logerrit)
 hwpfilter/source/hwpfile.cxx |   27 ++
 i18nlangtag/source/isolang/inunx.cxx |   80 +-
 idl/source/objects/slot.cxx  |   47 +-
 idlc/source/astdeclaration.cxx   |   51 +--
 idlc/source/astenum.cxx  |   60 ++---
 idlc/source/astscope.cxx |   51 +--
 idlc/source/options.cxx  |   74 -
 include/basegfx/range/basicrange.hxx |   26 +++---
 include/canvas/canvastools.hxx   |   32 +++
 include/comphelper/traceevent.hxx|   96 +++---
 include/cppuhelper/proptypehlp.hxx   |  151 +--
 include/salhelper/dynload.hxx|3 
 12 files changed, 346 insertions(+), 352 deletions(-)

New commits:
commit a3bc9dc51104d01ec203b8e2d5767dd055a42b58
Author: Noel Grandin 
AuthorDate: Tue Dec 21 15:26:54 2021 +0200
Commit: Noel Grandin 
CommitDate: Wed Dec 22 07:44:07 2021 +0100

loplugin:flatten in filter..include

Change-Id: I74c1ea8b9b490eaa9508a885758224063e39051b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127235
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index 171b7e1a9e8d..5f32a38c0633 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -596,23 +596,20 @@ void HWPFile::AddFBoxStyle(FBoxStyle * fbstyle)
 int HWPFile::compareCharShape(CharShape const *shape)
 {
 int count = cslist.size();
-if( count > 0 )
+for(int i = 0; i< count; i++)
 {
-for(int i = 0; i< count; i++)
+CharShape *cshape = getCharShape(i);
+
+if( shape->size == cshape->size &&
+shape->font[0] == cshape->font[0] &&
+shape->ratio[0] == cshape->ratio[0] &&
+shape->space[0] == cshape->space[0] &&
+shape->color[1] == cshape->color[1] &&
+shape->color[0] == cshape->color[0] &&
+shape->shade == cshape->shade &&
+shape->attr == cshape->attr )
 {
-CharShape *cshape = getCharShape(i);
-
-if( shape->size == cshape->size &&
-shape->font[0] == cshape->font[0] &&
-shape->ratio[0] == cshape->ratio[0] &&
-shape->space[0] == cshape->space[0] &&
-shape->color[1] == cshape->color[1] &&
-shape->color[0] == cshape->color[0] &&
-shape->shade == cshape->shade &&
-shape->attr == cshape->attr )
-{
-return cshape->index;
-}
+return cshape->index;
 }
 }
 return 0;
diff --git a/i18nlangtag/source/isolang/inunx.cxx 
b/i18nlangtag/source/isolang/inunx.cxx
index e8ad10059d24..4dd4cdb3531b 100644
--- a/i18nlangtag/source/isolang/inunx.cxx
+++ b/i18nlangtag/source/isolang/inunx.cxx
@@ -88,60 +88,60 @@ static void getPlatformSystemLanguageImpl( LanguageType& 
rSystemLanguage,
 {
 /* get the language from the user environment */
 LanguageType nLang = rSystemLanguage;
+if ( nLang != LANGUAGE_DONTKNOW )
+return;
+
+::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex());
+nLang = rSystemLanguage;
 if ( nLang == LANGUAGE_DONTKNOW )
 {
-::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex());
-nLang = rSystemLanguage;
-if ( nLang == LANGUAGE_DONTKNOW )
-{
 #ifdef MACOSX
-rtl_Locale*procLocale;
-(void) pGetLangFromEnv; /* unused */
+rtl_Locale*procLocale;
+(void) pGetLangFromEnv; /* unused */
 
-if ( osl_getProcessLocale() == osl_Process_E_None )
-{
-nLang = LanguageTag( *procLocale 
).makeFallback().getLanguageType();
-OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
-rSystemLanguage = nLang;
+if ( osl_getProcessLocale() == osl_Process_E_None )
+{
+nLang = LanguageTag( *procLocale 
).makeFallback().getLanguageType();
+OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+rSystemLanguage = nLang;
 #ifdef DEBUG
-if ( rSystemLanguage == LANGUAGE_DONTKNOW )
-fprintf( stderr, "intnunx.cxx:  failed to convert 
osl_getProcessLocale() language to system language.\n" );
+if ( rSystemLanguage == LANGUAGE_DONTKNOW )
+fprintf( stderr, "intnunx.cxx:  failed to convert 
osl_getProcessLocale() language to system language.\n" );
 #endif
-}
+}
 #else   /* MACOSX */
-bool bColonList = false;
-OString aUnxLang( pGetLangFromEnv( bColonList));
-if (bColonList)
+bool bColonList = false;
+OString aUnxLang( pGetLangFromEnv( bColonList));
+if (bColonList)
+{
+// Only a very simple "take first". If empty try second or keep 
empty.
+sal_Int32 n = 

[Libreoffice-commits] core.git: hwpfilter/source

2021-11-29 Thread Noel Grandin (via logerrit)
 hwpfilter/source/hwpreader.cxx |2 +-
 hwpfilter/source/hwpreader.hxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit ac52c6b58d30e0124b27a5b928261db5a4592c28
Author: Noel Grandin 
AuthorDate: Mon Nov 29 13:26:31 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Nov 29 14:52:19 2021 +0100

loplugin:stringliteraldefine in hwpfilter

Change-Id: Ibdd479533a8dc17df4fa2116299d81468f641a20
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126044
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 54684bb51eec..32d9b08c6d25 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -4869,7 +4869,7 @@ HwpImportFilter::HwpImportFilter(const Reference< 
XComponentContext >& rxContext
 }
 catch( Exception & )
 {
-printf(" fail to instantiate %s\n", WRITER_IMPORTER_NAME );
+printf(" fail to instantiate %s\n", 
OUString(WRITER_IMPORTER_NAME).toUtf8().getStr() );
 exit( 1 );
 }
 }
diff --git a/hwpfilter/source/hwpreader.hxx b/hwpfilter/source/hwpreader.hxx
index 7642d9324981..91021a326186 100644
--- a/hwpfilter/source/hwpreader.hxx
+++ b/hwpfilter/source/hwpreader.hxx
@@ -65,7 +65,7 @@ using namespace ::com::sun::star::xml::sax;
 #include "drawdef.h"
 #include "attributes.hxx"
 
-#define WRITER_IMPORTER_NAME "com.sun.star.comp.Writer.XMLImporter"
+inline constexpr OUStringLiteral WRITER_IMPORTER_NAME = 
u"com.sun.star.comp.Writer.XMLImporter";
 
 struct HwpReaderPrivate;
 /**


[Libreoffice-commits] core.git: hwpfilter/source lotuswordpro/inc lotuswordpro/source scaddins/source

2021-11-13 Thread Hossein (via logerrit)
 hwpfilter/source/hcode.cxx  |   18 ++-
 hwpfilter/source/hwpreader.cxx  |   45 +---
 lotuswordpro/inc/xfilter/xfdrawobj.hxx  |3 +
 lotuswordpro/inc/xfilter/xfglobal.hxx   |2 -
 lotuswordpro/source/filter/lwpdrawobj.cxx   |3 +
 scaddins/source/analysis/analysis.cxx   |2 -
 scaddins/source/analysis/analysishelper.hxx |6 ---
 7 files changed, 33 insertions(+), 46 deletions(-)

New commits:
commit 35c85effecb5a615a361c1b7d92d08447bc83423
Author: Hossein 
AuthorDate: Thu Nov 11 00:00:38 2021 +0100
Commit: Mike Kaganski 
CommitDate: Sun Nov 14 08:14:15 2021 +0100

Use M_PI instead of defined value; use rad2deg()

* Replace defined values of PI with M_PI defined in 
* Use M_PI_2 instead of PI / 2.0
* Instances could be found with:

git grep 3.14 *.cxx *.hxx|grep define

* One instance is ignored:

  sc/source/core/opencl/opinlinefun_statistical.cxx

* Replace *(180 / PI) with basegfx::rad2deg()
* Replace 2*PI/360 with basegfx::deg2rad()
* Use atan2 instead of atan where it was more appropriate
  + atan2() handles all 4 quadrants
  + Extra conditions for different quadrants are removed

Change-Id: I083ee2e1427cd36ba0b8c38e4fe5f782d6486075
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124229
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx
index ff133cebd25a..514e594a2c49 100644
--- a/hwpfilter/source/hcode.cxx
+++ b/hwpfilter/source/hcode.cxx
@@ -24,17 +24,16 @@
  * Special johap code => ks code => unicode
  */
 #include "precompile.h"
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include "hcode.h"
 #include "ksc5601.h"
 
-#define PI 3.14159265358979323846
-
 static hchar jaso2ks(hchar hh);
 
 // ccvHH2ASCcode convert HWP20 to ASC(KSSM)
@@ -1445,17 +1444,8 @@ double calcAngle(int x1, int y1, int x2, int y2)
 return 270.;
  }
  double angle;
- angle = (180 / PI) * atan( ( y2 - y1 ) * 1.0 / ( x2 - x1 ));
- if( y2 >= y1 ){ /* 1, 2 quadrant */
-  if( angle < 0. )
-angle += 180.;
- }
- else{ /* 3, 4 quadrants */
-  if( angle > 0 )
-angle += 180.;
-  else
-angle += 360.;
- }
+ // atan2 handles all 4 quadrants
+ angle = basegfx::rad2deg(atan2(y2 - y1 , x2 - x1));
  return angle;
 }
 
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index 43f48d535a0a..54684bb51eec 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -22,11 +22,12 @@
 #include 
 
 #include "hwpreader.hxx"
-#include 
+#include 
 
 #include 
 #include 
 #include 
+#include 
 
 #include "fontmap.hxx"
 #include "formula.h"
@@ -50,8 +51,6 @@
 #define WTMM(x) (static_cast(x) / 1800. * 25.4)  // unit => mm
 #define WTSM(x) (static_cast((x) / 1800. * 2540))   // unit ==> 1/100 
mm
 
-#define PI 3.14159265358979323846
-
 // xmloff/xmlkyd.hxx
 constexpr OUStringLiteral sXML_CDATA = u"CDATA";
 
@@ -4049,14 +4048,14 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, Picture * hbox)
 /* 2 - rotation angle calculation */
 if( pt[1].x == pt[0].x ){
  if( pt[1].y > pt[0].y )
- rotate = PI/2;
+ rotate = M_PI_2;
  else
- rotate = -(PI/2);
+ rotate = -M_PI_2;
 }
 else
 rotate = atan(static_cast( pt[1].y - pt[0].y 
)/(pt[1].x - pt[0].x ));
 if( pt[1].x < pt[0].x )
-rotate += PI;
+rotate += M_PI;
 
 for( i = 0 ; i < 3 ; i++){
  r_pt[i].x = static_cast(pt[i].x * cos(-rotate) - 
pt[i].y * sin(-rotate));
@@ -4068,10 +4067,10 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, Picture * hbox)
  skewX = 0;
 else
  skewX = atan(static_cast(r_pt[2].x - 
r_pt[1].x )/( r_pt[2].y - r_pt[1].y ));
-if( skewX >= PI/2 )
- skewX -= PI;
-if( skewX <= -PI/2 )
- skewX += PI;
+if( skewX >= M_PI_2 )
+ skewX -= M_PI;
+if( skewX <= -M_PI_2 )
+ skewX += M_PI;
 
 OUString trans;
 if( skewX != 0.0 && rotate != 0.0 ){
@@ -4264,38 +4263,38 @@ void HwpReader::makePictureDRAW(HWPDrawingObject 
*drawobj, Picture * hbox)
 
 if( pal->pt[1].x == pal->pt[0].x ){
 if( pal->pt[0].y < pal->pt[1].y )
- 

[Libreoffice-commits] core.git: hwpfilter/source

2021-11-05 Thread Noel Grandin (via logerrit)
 hwpfilter/source/hstyle.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit e495d0e5614e08f0eacdb5ea5deb0c1e0a0f3db4
Author: Noel Grandin 
AuthorDate: Fri Nov 5 15:17:42 2021 +0200
Commit: Noel Grandin 
CommitDate: Fri Nov 5 17:49:12 2021 +0100

update diagnostic ignore

problem still present in
   gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0

Change-Id: I5bc2115be0cda4a444f493645b86e60290c9d0fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124751
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/hwpfilter/source/hstyle.cxx b/hwpfilter/source/hstyle.cxx
index 33f143440c32..fbbe30025d0a 100644
--- a/hwpfilter/source/hstyle.cxx
+++ b/hwpfilter/source/hstyle.cxx
@@ -70,14 +70,14 @@ void HWPStyle::SetName(int n, char const* name)
 
 if (name)
 {
-#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 10) && !defined __clang__
+#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 11) && !defined __clang__
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wstringop-truncation"
 #endif
 auto const p = DATA[n].name;
 strncpy(p, name, MAXSTYLENAME);
 p[MAXSTYLENAME] = '\0'; // just in case, even though the array is 
zero-initialized
-#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 10) && !defined __clang__
+#if defined __GNUC__ && (__GNUC__ >= 8 && __GNUC__ <= 11) && !defined __clang__
 #pragma GCC diagnostic pop
 #endif
 }


[Libreoffice-commits] core.git: hwpfilter/source

2021-10-13 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hpara.cxx   |2 +-
 hwpfilter/source/hpara.h |2 +-
 hwpfilter/source/htags.cxx   |2 +-
 hwpfilter/source/hwpfile.cxx |6 --
 hwpfilter/source/hwpfile.h   |5 +
 hwpfilter/source/hwpread.cxx |8 
 6 files changed, 8 insertions(+), 17 deletions(-)

New commits:
commit 4fed3b2ed15730fcb7a5b7e0ef09d77bd40436e6
Author: Caolán McNamara 
AuthorDate: Tue Oct 12 20:59:26 2021 +0100
Commit: Caolán McNamara 
CommitDate: Wed Oct 13 11:02:05 2021 +0200

ditch problematic HWPFile::Read4b variant

Change-Id: Ied3603d8f96e15013f657fc5d8150969ae3b808d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123534
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hpara.cxx b/hwpfilter/source/hpara.cxx
index 415c8e984eb3..736188f1ad9e 100644
--- a/hwpfilter/source/hpara.cxx
+++ b/hwpfilter/source/hpara.cxx
@@ -98,7 +98,7 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag)
 hwpf.Read2b(, 1);
 hwpf.Read1b(contain_cshape);
 hwpf.Read1b(etcflag);
-hwpf.Read4b(, 1);
+hwpf.Read4b(ctrlflag);
 hwpf.Read1b(pstyno);
 
 /* Paragraph representative character */
diff --git a/hwpfilter/source/hpara.h b/hwpfilter/source/hpara.h
index d3b0b788970e..58694899ea38 100644
--- a/hwpfilter/source/hpara.h
+++ b/hwpfilter/source/hpara.h
@@ -104,7 +104,7 @@ class DLLEXPORT HWPPara
 /**
  * Checks the special characters in the paragraph
  */
-tools::ULong  ctrlflag;
+uint  ctrlflag;
 unsigned char pstyno;
 std::shared_ptr cshape; /* When 
characters are all the same shape */
 std::shared_ptr pshape; /* if reuse 
flag is 0, */
diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx
index 334e2b0f3b47..b8cafcf38675 100644
--- a/hwpfilter/source/htags.cxx
+++ b/hwpfilter/source/htags.cxx
@@ -98,7 +98,7 @@ void OlePicture::Read(HWPFile & hwpf)
 return;
 
 // We process only FILESTG_SIGNATURE_NORMAL.
-hwpf.Read4b(, 1);
+hwpf.Read4b(signature);
 if (signature != FILESTG_SIGNATURE_NORMAL)
 return;
 #ifdef _WIN32
diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index 3f67111691c4..171b7e1a9e8d 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -158,12 +158,6 @@ size_t HWPFile::Read2b(void *ptr, size_t nmemb)
 return hiodev ? hiodev->read2b(ptr, nmemb) : 0;
 }
 
-void HWPFile::Read4b(void *ptr, size_t nmemb)
-{
-if (hiodev)
-hiodev->read4b(ptr, nmemb);
-}
-
 size_t HWPFile::ReadBlock(void *ptr, size_t size)
 {
 return hiodev ? hiodev->readBlock(ptr, size) : 0;
diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h
index 9cc3b72a7c65..867a05fb7418 100644
--- a/hwpfilter/source/hwpfile.h
+++ b/hwpfilter/source/hwpfile.h
@@ -139,10 +139,7 @@ class DLLEXPORT HWPFile
  * Reads nmemb short type array from HIODev
  */
 size_t Read2b(void *ptr, size_t nmemb);
-/**
- * Reads nmemb long type array from HIODev
- */
-void Read4b( void *ptr, size_t nmemb );
+
 /**
  * Reads some bytes from HIODev not regarding endian's way
  * @param size Amount for reading
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index c81aaa153797..8e4a96c726d0 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -46,7 +46,7 @@ bool HBox::Read(HWPFile & )
 bool SkipData::Read(HWPFile & hwpf)
 {
 uint data_block_len;
-hwpf.Read4b(_block_len, 1);
+hwpf.Read4b(data_block_len);
 
 hchar dummy;
 if (!hwpf.Read2b(dummy))
@@ -73,7 +73,7 @@ bool FieldCode::Read(HWPFile & hwpf)
 if (!hwpf.Read2b(dummy))
 return false;
 hwpf.ReadBlock(, 2);
-hwpf.Read4b(reserved1.data(), 1);
+hwpf.ReadBlock(reserved1.data(), 4);
 if (!hwpf.Read2b(location_info))
 return false;
 hwpf.ReadBlock(reserved2.data(), 22);
@@ -123,7 +123,7 @@ bool Bookmark::Read(HWPFile & hwpf)
 {
 uint len;
 
-hwpf.Read4b(, 1);
+hwpf.Read4b(len);
 if (!hwpf.Read2b(dummy))
 return false;
 
@@ -402,7 +402,7 @@ bool Picture::Read(HWPFile & hwpf)
 }
 hwpf.AddBox(this);
 
-hwpf.Read4b(_block_size, 1);
+hwpf.Read4b(follow_block_size);
 
 //when fuzzing with a max len set, max decompress to 10 times that limit
 static size_t nMaxAllowedDecompression = [](const char* pEnv) { size_t 
nRet = pEnv ? std::atoi(pEnv) : 0; return nRet * 10; 
}(std::getenv("FUZZ_MAX_INPUT_LEN"));


[Libreoffice-commits] core.git: hwpfilter/source

2021-10-13 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpread.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit d2cf8e960eb352e547350e5aed7a44873697b396
Author: Caolán McNamara 
AuthorDate: Tue Oct 12 20:50:58 2021 +0100
Commit: Caolán McNamara 
CommitDate: Wed Oct 13 09:41:41 2021 +0200

ofz: nLen should be of type 'uint' not tools::Long

Change-Id: If0ea7d2156511b325e866f79bf40e32418f7d658
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123533
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 31da8c7efde7..c81aaa153797 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -121,7 +121,7 @@ bool FieldCode::Read(HWPFile & hwpf)
 // book mark(6)
 bool Bookmark::Read(HWPFile & hwpf)
 {
-tools::Long len;
+uint len;
 
 hwpf.Read4b(, 1);
 if (!hwpf.Read2b(dummy))


[Libreoffice-commits] core.git: hwpfilter/source i18npool/source io/source jvmaccess/workbench jvmfwk/plugins

2021-10-05 Thread Julien Nabet (via logerrit)
 hwpfilter/source/hwpeq.cxx  |   25 ++
 i18npool/source/localedata/LocaleNode.cxx   |7 +---
 io/source/stm/opump.cxx |1 
 jvmaccess/workbench/javainfo/javainfotest.cxx   |5 +-
 jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx|7 +---
 jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx  |2 -
 jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx |9 ++---
 jvmfwk/plugins/sunmajor/pluginlib/sunjre.cxx|2 -
 jvmfwk/plugins/sunmajor/pluginlib/util.cxx  |   35 +---
 jvmfwk/plugins/sunmajor/pluginlib/vendorbase.cxx|7 +---
 10 files changed, 44 insertions(+), 56 deletions(-)

New commits:
commit 3068ab9a2c9307cbea2efa2b6924ce427bb54466
Author: Julien Nabet 
AuthorDate: Tue Oct 5 20:42:00 2021 +0200
Commit: Julien Nabet 
CommitDate: Tue Oct 5 22:22:55 2021 +0200

drop 'using namespace std' in h* i* j*

Change-Id: I3c28651779f17e1a410505ffaa863b4773037ccf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123119
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/hwpfilter/source/hwpeq.cxx b/hwpfilter/source/hwpeq.cxx
index f2325508fc9f..a19bee24acbb 100644
--- a/hwpfilter/source/hwpeq.cxx
+++ b/hwpfilter/source/hwpeq.cxx
@@ -24,7 +24,6 @@
 // DVO: always use standard headers:
 #include 
 #include 
-using namespace std;
 
 #include "mzstring.h"
 #include "hwpeq.h"
@@ -65,8 +64,8 @@ static bool IS_BINARY(std::istream::int_type ch) {
 // sub and sup script status
 enum { SCRIPT_NONE, SCRIPT_SUB, SCRIPT_SUP, SCRIPT_ALL};
 
-static int  eq_word(MzString& outs, istream *strm, int script = SCRIPT_NONE);
-static bool eq_sentence(MzString& outs, istream *strm, const char *end = 
nullptr);
+static int  eq_word(MzString& outs, std::istream *strm, int script = 
SCRIPT_NONE);
+static bool eq_sentence(MzString& outs, std::istream *strm, const char *end = 
nullptr);
 
 namespace {
 
@@ -462,10 +461,10 @@ namespace {
 struct eq_stack {
   MzString  white;
   MzString  token;
-  istream   *strm;
+  std::istream   *strm;
 
   eq_stack() { strm = nullptr; };
-  bool state(istream const *s) {
+  bool state(std::istream const *s) {
 if( strm != s) { white = nullptr; token = nullptr; }
 return token.length() != 0;
   }
@@ -475,7 +474,7 @@ struct eq_stack {
 
 static eq_stack *stk = nullptr;
 
-static void push_token(MzString const , MzString const , istream 
*strm)
+static void push_token(MzString const , MzString const , 
std::istream *strm)
 {
   // one time stack
   assert(stk->token.length() == 0);
@@ -490,7 +489,7 @@ static void push_token(MzString const , MzString 
const , istream *st
  *
  * control char, control sequence, binary sequence,
  * alphabet string, single character */
-static int next_token(MzString , MzString , istream *strm)
+static int next_token(MzString , MzString , std::istream *strm)
 {
   std::istream::int_type ch = 0;
 
@@ -571,7 +570,7 @@ static int next_token(MzString , MzString , 
istream *strm)
   return token.length();
 }
 
-static std::istream::int_type read_white_space(MzString& outs, istream *strm)
+static std::istream::int_type read_white_space(MzString& outs, std::istream 
*strm)
 {
   std::istream::int_type result;
 
@@ -609,7 +608,7 @@ static std::istream::int_type read_white_space(MzString& 
outs, istream *strm)
   a over b -> {a} over {b}
  */
 
-static int eq_word(MzString& outs, istream *strm, int status)
+static int eq_word(MzString& outs, std::istream *strm, int status)
 {
   MzString  token, white, state;
   int   result;
@@ -677,7 +676,7 @@ static int eq_word(MzString& outs, istream *strm, int 
status)
   return result;
 }
 
-static bool eq_sentence(MzString& outs, istream *strm, const char *end)
+static bool eq_sentence(MzString& outs, std::istream *strm, const char *end)
 {
   MzString  state;
   MzString  white, token;
@@ -706,7 +705,7 @@ static bool eq_sentence(MzString& outs, istream *strm, 
const char *end)
   return multiline;
 }
 
-static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel)
+static char eq2ltxconv(MzString& sstr, std::istream *strm, const char 
*sentinel)
 {
   MzString  white, token;
   char  key[256];
@@ -784,9 +783,9 @@ void eq2latex(MzString& outs, char const *s)
 
   MzString  tstr;
 
-  istringstream tstrm(s);
+  std::istringstream tstrm(s);
   bool eqnarray = eq_sentence(tstr, );
-  istringstream strm(tstr.c_str());
+  std::istringstream strm(tstr.c_str());
 
   if( eqnarray )
 outs << "\\begin{array}{r}" << ENDL;
diff --git a/i18npool/source/localedata/LocaleNode.cxx 
b/i18npool/source/localedata/LocaleNode.cxx
index 8c23e3a29b21..e1443b1e1d0f 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -41,7 +41,6 @@ typedef ::o3tl::sorted_vector< OUString > NameSet;
 typedef ::o3tl::sorted_vector< sal_Int16 > ValueSet;
 
 namespace cssi = ::com::sun::star::i18n;
-using namespace std;
 

[Libreoffice-commits] core.git: hwpfilter/source

2021-09-03 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpread.cxx |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 27b84d7460cbb925429826d20c4cee5439ad7053
Author: Caolán McNamara 
AuthorDate: Thu Sep 2 12:02:55 2021 +0100
Commit: Caolán McNamara 
CommitDate: Fri Sep 3 12:05:37 2021 +0200

cid#1490898 Unchecked return value

Change-Id: I49124165e0d00d84f3ebdb0414d6db58f6da1209
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121519
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index de69eb4cd004..31da8c7efde7 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -70,17 +70,17 @@ bool FieldCode::Read(HWPFile & hwpf)
 uint binlen; /* Length of any binary data format */
 
 hwpf.Read4b(size);
-hwpf.Read2b(dummy);
+if (!hwpf.Read2b(dummy))
+return false;
 hwpf.ReadBlock(, 2);
 hwpf.Read4b(reserved1.data(), 1);
-hwpf.Read2b(location_info);
+if (!hwpf.Read2b(location_info))
+return false;
 hwpf.ReadBlock(reserved2.data(), 22);
 hwpf.Read4b(len1);
 hwpf.Read4b(len2);
 hwpf.Read4b(len3);
-bool bSuccess = hwpf.Read4b(binlen);
-
-if (!bSuccess)
+if (!hwpf.Read4b(binlen))
 return false;
 
 uint const len1_ = std::min(len1, 1024) / sizeof(hchar);


[Libreoffice-commits] core.git: hwpfilter/source

2021-08-31 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpread.cxx |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

New commits:
commit 7a410f7ee447201dc23b31166ca9989a3c01bce7
Author: Caolán McNamara 
AuthorDate: Tue Aug 31 09:17:18 2021 +0100
Commit: Caolán McNamara 
CommitDate: Tue Aug 31 22:21:56 2021 +0200

ofz: MemorySanitizer: use-of-uninitialized-value

Change-Id: I0e671742043662aec27751974223b205d24508aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121387
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 62989bcf022d..de69eb4cd004 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -38,20 +38,19 @@ static int lnnumber = 0;
 
 bool HBox::Read(HWPFile & )
 {
-// already read
+// already read
 return true;
 }
 
-
 // skip block
-
 bool SkipData::Read(HWPFile & hwpf)
 {
 uint data_block_len;
 hwpf.Read4b(_block_len, 1);
 
 hchar dummy;
-hwpf.Read2b(, 1);
+if (!hwpf.Read2b(dummy))
+return hwpf.SetState(HWP_InvalidFileFormat);
 
 if (!(IS_SP_SKIP_BLOCK(hh) && (hh == dummy))){
 return hwpf.SetState(HWP_InvalidFileFormat);


[Libreoffice-commits] core.git: hwpfilter/source

2021-08-31 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpread.cxx |   20 
 1 file changed, 12 insertions(+), 8 deletions(-)

New commits:
commit 0ec44b738b92bbf6965bf0dbe41199476673dcaf
Author: Caolán McNamara 
AuthorDate: Mon Aug 30 15:27:04 2021 +0100
Commit: Caolán McNamara 
CommitDate: Tue Aug 31 12:30:14 2021 +0200

ofz: MemorySanitizer: use-of-uninitialized-value

check for short reads

Change-Id: I1fb142e08f5664ca73dc62f6c5a5ecfd2ee1e875
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121352
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index d739e033f65b..62989bcf022d 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -70,16 +70,19 @@ bool FieldCode::Read(HWPFile & hwpf)
 uint len3;   /* Length of hchar type string DATA #3 */
 uint binlen; /* Length of any binary data format */
 
-hwpf.Read4b(, 1);
-hwpf.Read2b(, 1);
+hwpf.Read4b(size);
+hwpf.Read2b(dummy);
 hwpf.ReadBlock(, 2);
 hwpf.Read4b(reserved1.data(), 1);
-hwpf.Read2b(_info, 1);
+hwpf.Read2b(location_info);
 hwpf.ReadBlock(reserved2.data(), 22);
-hwpf.Read4b(, 1);
-hwpf.Read4b(, 1);
-hwpf.Read4b(, 1);
-hwpf.Read4b(, 1);
+hwpf.Read4b(len1);
+hwpf.Read4b(len2);
+hwpf.Read4b(len3);
+bool bSuccess = hwpf.Read4b(binlen);
+
+if (!bSuccess)
+return false;
 
 uint const len1_ = std::min(len1, 1024) / sizeof(hchar);
 uint const len2_ = std::min(len2, 1024) / sizeof(hchar);
@@ -95,7 +98,8 @@ bool FieldCode::Read(HWPFile & hwpf)
 hwpf.Read2b(str2.get(), len2_);
 hwpf.SkipBlock(len2 - (len2_ * sizeof(hchar)));
 str2[len2_ ? (len2_ - 1) : 0] = 0;
-hwpf.Read2b(str3.get(), len3_);
+if (hwpf.Read2b(str3.get(), len3_) != len3_)
+return false;
 hwpf.SkipBlock(len3 - (len3_ * sizeof(hchar)));
 str3[len3_ ? (len3_ - 1) : 0] = 0;
 


[Libreoffice-commits] core.git: hwpfilter/source

2021-08-31 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/htags.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit fc3bacf7e02af57781a9d63581abc96d66d6529f
Author: Caolán McNamara 
AuthorDate: Mon Aug 30 15:43:37 2021 +0100
Commit: Caolán McNamara 
CommitDate: Tue Aug 31 12:29:53 2021 +0200

ofz: MemorySanitizer: use-of-uninitialized-value

Change-Id: Id877653f5c120f690fc3f597979de88926ec6ab0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121354
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx
index d0a7d772ce15..334e2b0f3b47 100644
--- a/hwpfilter/source/htags.cxx
+++ b/hwpfilter/source/htags.cxx
@@ -32,6 +32,8 @@ bool HyperText::Read(HWPFile& hwpf)
 nRead += hwpf.ReadBlock(macro, 325);
 if (hwpf.Read1b(type))
 ++nRead;
+else
+type = 0;
 nRead += hwpf.ReadBlock(reserve, 3);
 if( type == 2 )
 {


[Libreoffice-commits] core.git: hwpfilter/source

2021-08-29 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hgzip.cxx   |3 +++
 hwpfilter/source/hwpread.cxx |2 --
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 8d07df00118b5ac82880fdea000df350c3bf379c
Author: Caolán McNamara 
AuthorDate: Sun Aug 29 15:56:31 2021 +0100
Commit: Caolán McNamara 
CommitDate: Sun Aug 29 17:54:29 2021 +0200

ofz: MemorySanitizer: use-of-uninitialized-value

Change-Id: Ibe0f0307d939d8ce54ffdf54ae42948bfa22303a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121228
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hgzip.cxx b/hwpfilter/source/hgzip.cxx
index 56dc6268c273..ed8ef8a75f54 100644
--- a/hwpfilter/source/hgzip.cxx
+++ b/hwpfilter/source/hgzip.cxx
@@ -156,6 +156,9 @@ size_t gz_read(gz_stream * file, voidp buf, unsigned len)
 if (s == nullptr)
 return 0;
 
+if (s->z_eof)
+return 0;
+
 if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)
 return 0;
 if (s->z_err == Z_STREAM_END)
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 45d156b00399..d739e033f65b 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -502,8 +502,6 @@ bool Picture::Read(HWPFile & hwpf)
 ishyper = true;
 }
 }
-else
-fprintf(stderr, "arse\n");
 }
 
 if( pictype != 3 )


[Libreoffice-commits] core.git: hwpfilter/source

2021-08-14 Thread Yildiray (via logerrit)
 hwpfilter/source/hcode.h |6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

New commits:
commit 768722ea12779e5c533d691c311b63490e2279d0
Author: Yildiray 
AuthorDate: Sun Aug 8 22:19:26 2021 +0300
Commit: Ilmari Lauhakangas 
CommitDate: Sat Aug 14 15:12:36 2021 +0200

tdf#143148: Use pragma once in sdext

Change-Id: Ic626b9064d9bcd024f938bbd43375bc3fff5838f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120178
Tested-by: Ilmari Lauhakangas 
Reviewed-by: Ilmari Lauhakangas 

diff --git a/hwpfilter/source/hcode.h b/hwpfilter/source/hcode.h
index 18ec72a3d6e8..3fb2da528ef7 100644
--- a/hwpfilter/source/hcode.h
+++ b/hwpfilter/source/hcode.h
@@ -17,8 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_HWPFILTER_SOURCE_HCODE_H
-#define INCLUDED_HWPFILTER_SOURCE_HCODE_H
+#pragma once
 
 #include "hwplib.h"
 
@@ -70,7 +69,4 @@ DLLEXPORT char *hcolor2str(uchar color, uchar shade, char 
*buf, bool bIsChar = f
 DLLEXPORT char *base64_encode_string( const uchar *buf, unsigned int len );
 DLLEXPORT double calcAngle(int x1, int y1, int x2, int y2);
 
-
-#endif // INCLUDED_HWPFILTER_SOURCE_HCODE_H
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


[Libreoffice-commits] core.git: hwpfilter/source lotuswordpro/source

2021-07-19 Thread Andrea Gelmini (via logerrit)
 hwpfilter/source/hwpfile.cxx   |2 +-
 hwpfilter/source/hwpread.cxx   |2 +-
 lotuswordpro/source/filter/bencont.cxx |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 3cbdff0a01aa353f281e8d05277b52c09444944f
Author: Andrea Gelmini 
AuthorDate: Sun Jul 18 23:16:13 2021 +0200
Commit: Julien Nabet 
CommitDate: Mon Jul 19 19:49:09 2021 +0200

Fix typo

Change-Id: I8babf7975eb3b8f3e43f72572e75cbf46f510b20
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119147
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index 762bb31d0582..3f67111691c4 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -361,7 +361,7 @@ void HWPFile::TagsRead()
 
  _hwpInfo.back_info.data.clear();
 
- //read potentially compressed data in blocks as its more
+ //read potentially compressed data in blocks as it's more
  //likely large values are simply broken and we'll run out
  //of data before we need to realloc
  for (int i = 0; i < _hwpInfo.back_info.size; i+= 
SAL_MAX_UINT16)
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index be8cdc7bb82d..45d156b00399 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -469,7 +469,7 @@ bool Picture::Read(HWPFile & hwpf)
 {
 follow.clear();
 
-//read potentially compressed data in blocks as its more
+//read potentially compressed data in blocks as it's more
 //likely large values are simply broken and we'll run out
 //of data before we need to realloc
 for (size_t i = 0; i < follow_block_size; i+= 
SAL_N_ELEMENTS(hwpf.scratch))
diff --git a/lotuswordpro/source/filter/bencont.cxx 
b/lotuswordpro/source/filter/bencont.cxx
index a7d1a5727875..b5648a64b3ec 100644
--- a/lotuswordpro/source/filter/bencont.cxx
+++ b/lotuswordpro/source/filter/bencont.cxx
@@ -248,7 +248,7 @@ namespace
 {
 void readDataInBlocks(SvStream& rSt, sal_uInt64 nDLen, 
std::vector& rData)
 {
-//read data in blocks as its more likely large values are simply broken
+//read data in blocks as it's more likely large values are simply 
broken
 //and we'll run out of data before we need to realloc
 for (sal_uInt64 i = 0; i < nDLen; i+= SAL_MAX_UINT16)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: hwpfilter/source

2021-07-01 Thread Caolán McNamara (via logerrit)
 hwpfilter/source/hwpfile.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 567922d076cfaf90c11c32c34e8a4955c9248b9b
Author: Caolán McNamara 
AuthorDate: Thu Jul 1 09:49:01 2021 +0100
Commit: Caolán McNamara 
CommitDate: Thu Jul 1 12:27:18 2021 +0200

ofz#33724 compareParaShape will return 0 if input shape has no cshape

so return early in that case and avoid the expensive loop

Change-Id: Ibdde814322c6e9c094c3652c28e0d79887d1f5bd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118211
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx
index 3fbaf6c6f2fc..3a2d2c282e9b 100644
--- a/hwpfilter/source/hwpfile.cxx
+++ b/hwpfilter/source/hwpfile.cxx
@@ -626,6 +626,9 @@ int HWPFile::compareCharShape(CharShape const *shape)
 
 int HWPFile::compareParaShape(const ParaShape* shape)
 {
+if (!shape->cshape)
+return 0;
+
 int count = pslist.size();
 if (count > 0)
 {
@@ -642,7 +645,7 @@ int HWPFile::compareParaShape(const ParaShape* shape)
 shape->outline == pshape->outline &&
 shape->pagebreak == pshape->pagebreak)
 {
-if (shape->cshape && pshape->cshape &&
+if (pshape->cshape &&
 shape->cshape->size == pshape->cshape->size &&
 shape->cshape->font[0] == pshape->cshape->font[0] &&
 shape->cshape->ratio[0] == pshape->cshape->ratio[0] &&
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


  1   2   3   >