summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-19 04:58:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-19 04:58:09 +0000
commitfba998af1b17e852325c14cd0eaabed7beafb0fb (patch)
tree5a94fed5e441970a8761231b0e5acb790fc3ac5c /pack.c
parent3cff13cb2c8df5072edc90f99cf1631a0e5b86a5 (diff)
* parse.y (parse_regx): should raise error on untermitated
expression interpolation. * pack.c (pack_unpack): should give length to utf8_to_uv(). * pack.c (utf8_to_uv): add length check. * eval.c (rb_thread_wait_for): select may cause ERESTART on Solaris. * eval.c (rb_thread_select): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/pack.c b/pack.c
index 9e05f46c5a..0d309d5598 100644
--- a/pack.c
+++ b/pack.c
@@ -1456,12 +1456,12 @@ pack_unpack(str, fmt)
case 'U':
if (len > send - s) len = send - s;
- while (len-- > 0 && s < send) {
- int alen;
+ while (len > 0 && s < send) {
+ int alen = len;
unsigned long l;
l = utf8_to_uv(s, &alen);
- s += alen;
+ s += alen; len -= alen;
rb_ary_push(ary, rb_uint2inum(l));
}
break;
@@ -1757,6 +1757,7 @@ utf8_to_uv(p, lenp)
else if (c < 0xfc) n = 5;
else if (c < 0xfe) n = 6;
else if (c == 0xfe) n = 7;
+ if (n > *lenp) return 0;
*lenp = n--;
uv = c;