summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxhe <xw897002528@gmail.com>2018-12-17 12:36:38 +0800
committerrofl0r <retnyg@gmx.net>2019-01-16 02:38:18 +0000
commit37625860c85818861bab8f86ed0aeb41bb705fc7 (patch)
treec74827449897e40bf0b1a36496e26384a84221c6
parentc71556cc2f9e11bfa17e4322c15f58a957e0205b (diff)
downloadgettext-tiny-37625860c85818861bab8f86ed0aeb41bb705fc7.tar.gz
poparser: avoid 32-bit truncation by unsigned
as rofl0r said, unsigned on x86/x64 is 32 bits, and will truncate the len. though the result of sizeof() should just be a very small number( 12), and truncation will not effect the check result.
-rw-r--r--src/poparser.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/poparser.c b/src/poparser.c
index 8cd1fe1..6254f7e 100644
--- a/src/poparser.c
+++ b/src/poparser.c
@@ -1,5 +1,6 @@
#include <ctype.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <iconv.h>
#include "poparser.h"
@@ -56,7 +57,7 @@ static inline enum po_error poparser_feed_hdr(struct po_parser *p, po_message_t
if ((x = strstr(msg->str[0], "charset="))) {
for (y = x; *y && !isspace(*y); y++);
- if ((unsigned)(y-x-7) > sizeof(p->hdr.charset))
+ if ((uintptr_t)(y-x-7) > sizeof(p->hdr.charset))
return -po_unsupported_charset;
memcpy(p->hdr.charset, x+8, y-x-8);