summaryrefslogtreecommitdiffstats
path: root/lib/libarchive
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-08-08 02:22:48 +0000
committerkientzle <kientzle@FreeBSD.org>2004-08-08 02:22:48 +0000
commit6b8c5a5e67931e028e3dc8aaee14961eda10dab8 (patch)
tree183f73ec4ffe4124683eedb00456daec1079c2d4 /lib/libarchive
parent92956ea0cd6a94375374708ae3ac9ef76311b0ca (diff)
downloadFreeBSD-src-6b8c5a5e67931e028e3dc8aaee14961eda10dab8.zip
FreeBSD-src-6b8c5a5e67931e028e3dc8aaee14961eda10dab8.tar.gz
Oops. Use "unsigned long" instead of "int" for the intermediate variables
in wide-character conversions, since it's guaranteed to be large enough. Thanks to: Andrey Chernov
Diffstat (limited to 'lib/libarchive')
-rw-r--r--lib/libarchive/archive_read_support_format_tar.c2
-rw-r--r--lib/libarchive/archive_write_set_format_pax.c14
2 files changed, 7 insertions, 9 deletions
diff --git a/lib/libarchive/archive_read_support_format_tar.c b/lib/libarchive/archive_read_support_format_tar.c
index 76a228e..e91ddc4 100644
--- a/lib/libarchive/archive_read_support_format_tar.c
+++ b/lib/libarchive/archive_read_support_format_tar.c
@@ -1519,7 +1519,7 @@ static size_t
UTF8_mbrtowc(wchar_t *pwc, const char *s, size_t n)
{
int ch, i, len, mask;
- int lbound, wch;
+ unsigned long lbound, wch;
if (s == NULL)
/* Reset to initial shift state (no-op) */
diff --git a/lib/libarchive/archive_write_set_format_pax.c b/lib/libarchive/archive_write_set_format_pax.c
index 307ee1d..f5ee4c6 100644
--- a/lib/libarchive/archive_write_set_format_pax.c
+++ b/lib/libarchive/archive_write_set_format_pax.c
@@ -188,15 +188,13 @@ add_pax_attr_w(struct archive_string *as, const char *key, const wchar_t *wval)
{
int utf8len;
const wchar_t *wp;
- int wc;
+ unsigned long wc;
char *utf8_value, *p;
utf8len = 0;
for (wp = wval; *wp != L'\0'; ) {
wc = *wp++;
- if (wc <= 0) {
- /* Ignore negative values. */
- } else if (wc <= 0x7f)
+ if (wc <= 0x7f)
utf8len++;
else if (wc <= 0x7ff)
utf8len += 2;
@@ -206,16 +204,15 @@ add_pax_attr_w(struct archive_string *as, const char *key, const wchar_t *wval)
utf8len += 4;
else if (wc <= 0x3ffffff)
utf8len += 5;
- else
+ else if (wc <= 0x7fffffff)
utf8len += 6;
+ /* Ignore larger values; UTF-8 can't encode them. */
}
utf8_value = malloc(utf8len + 1);
for (wp = wval, p = utf8_value; *wp != L'\0'; ) {
wc = *wp++;
- if (wc <= 0) {
- /* Ignore negative values. */
- } else if (wc <= 0x7f) {
+ if (wc <= 0x7f) {
*p++ = (char)wc;
} else if (wc <= 0x7ff) {
p[0] = 0xc0 | ((wc >> 6) & 0x1f);
@@ -248,6 +245,7 @@ add_pax_attr_w(struct archive_string *as, const char *key, const wchar_t *wval)
p[4] = 0x80 | (wc & 0x3f);
p += 6;
}
+ /* Ignore larger values; UTF-8 can't encode them. */
}
*p = '\0';
add_pax_attr(as, key, utf8_value);
OpenPOWER on IntegriCloud