summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxhe <xw897002528@gmail.com>2018-12-16 18:49:02 +0800
committerrofl0r <retnyg@gmx.net>2019-01-16 02:38:18 +0000
commitc71556cc2f9e11bfa17e4322c15f58a957e0205b (patch)
treea9b055250b4e2cac9f973c9cc869430b0431f185
parent225a2dc144174d14f9f653cb95d99207d1267352 (diff)
downloadgettext-tiny-c71556cc2f9e11bfa17e4322c15f58a957e0205b.tar.gz
poparser: convert codecs at both two stages
as iconv may increase the length of strings, so we may have a larger length at the parse stage than the first stage. that leads to a memory corruption.
-rw-r--r--src/poparser.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/poparser.c b/src/poparser.c
index 190a8f2..8cd1fe1 100644
--- a/src/poparser.c
+++ b/src/poparser.c
@@ -82,13 +82,13 @@ static inline enum po_error poparser_feed_hdr(struct po_parser *p, po_message_t
static inline enum po_error poparser_clean(struct po_parser *p, po_message_t msg) {
enum po_error t;
+ if ((t = poparser_feed_hdr(p, msg)) != po_success) {
+ return t;
+ }
+
if (p->strcnt) {
msg->strlen[p->strcnt] = 0;
- if ((t = poparser_feed_hdr(p, msg)) != po_success) {
- return t;
- }
-
// PO_SYSDEP_PRIUMAX == 0, it has no effects to our codes
switch (msg->sysdep) {
case PO_SYSDEP_PRIU32: