diff options
-rw-r--r-- | hwpfilter/source/hfont.cxx | 4 | ||||
-rw-r--r-- | hwpfilter/source/hstyle.cxx | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/hwpfilter/source/hfont.cxx b/hwpfilter/source/hfont.cxx index e5c23a88199b..1a96b1797463 100644 --- a/hwpfilter/source/hfont.cxx +++ b/hwpfilter/source/hfont.cxx @@ -47,7 +47,9 @@ void HWPFont::AddFont(int lang, const char *font) nfonts = nFonts[lang]; if (MAXFONTS <= nfonts) return; - strncpy(fontnames[lang].get() + FONTNAMELEN * nfonts, font, FONTNAMELEN - 1); + auto const p = fontnames[lang].get() + FONTNAMELEN * nfonts; + strncpy(p, font, FONTNAMELEN - 1); + p[FONTNAMELEN - 1] = '\0'; // just in case, even though the array is zero-initialized nFonts[lang]++; } diff --git a/hwpfilter/source/hstyle.cxx b/hwpfilter/source/hstyle.cxx index cc3ef07cc987..87fd1efbe978 100644 --- a/hwpfilter/source/hstyle.cxx +++ b/hwpfilter/source/hstyle.cxx @@ -66,7 +66,18 @@ void HWPStyle::SetName(int n, char const *name) if (n >= 0 && n < nstyles) { if (name) - strncpy(DATA[n].name, name, MAXSTYLENAME); + { +#if defined __GNUC__ && __GNUC__ == 8 && __GNUC_MINOR__ == 2 && !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_MINOR__ == 2 && !defined __clang__ +#pragma GCC diagnostic pop +#endif + } else DATA[n].name[0] = 0; } |