summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-04 04:58:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-08-04 04:58:25 +0000
commitfc4907f25d5b6a6f89e778ec81b400e6f1661556 (patch)
tree705a77cc851e16ef59d85d7d6fa05e68539f621a /pack.c
parent05bc15b0ecab56b0e930a4608e49b81764817b11 (diff)
* pack.c (pack_pack): check argument overrun for 'P'. based on a
patch by rucila <rucila at yahoo.cojp>. fixed: [ruby-dev:29182] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/pack.c b/pack.c
index 4bfb95f..d58792f 100644
--- a/pack.c
+++ b/pack.c
@@ -364,7 +364,7 @@ num2i32(x)
#else
# define QUAD_SIZE 8
#endif
-static char *toofew = "too few arguments";
+static const char toofew[] = "too few arguments";
static void encodes _((VALUE,char*,long,int));
static void qpencode _((VALUE,VALUE,long));
@@ -460,8 +460,9 @@ pack_pack(ary, fmt)
items = RARRAY(ary)->len;
idx = 0;
-#define THISFROM RARRAY(ary)->ptr[idx]
-#define NEXTFROM (items-- > 0 ? RARRAY(ary)->ptr[idx++] : (rb_raise(rb_eArgError, toofew),0))
+#define TOO_FEW (rb_raise(rb_eArgError, toofew), 0)
+#define THISFROM (items > 0 ? RARRAY(ary)->ptr[idx] : TOO_FEW)
+#define NEXTFROM (items-- > 0 ? RARRAY(ary)->ptr[idx++] : TOO_FEW)
while (p < pend) {
if (RSTRING(fmt)->ptr + RSTRING(fmt)->len != pend) {
@@ -494,7 +495,7 @@ pack_pack(ary, fmt)
}
if (*p == '*') { /* set data length */
len = strchr("@Xxu", type) ? 0 : items;
- p++;
+ p++;
}
else if (ISDIGIT(*p)) {
len = strtoul(p, (char**)&p, 10);