summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorJindrich Novy <jnovy@redhat.com>2008-05-06 08:46:50 +0200
committerJindrich Novy <jnovy@redhat.com>2008-05-06 08:46:50 +0200
commit90eec724a834c26131be11145a62084efe3bafb8 (patch)
tree8c9fb977fa469f1f25294465f161da1fe74d9e91 /build
parent697f27bbbab27a2f353803bf765f334b8668b59d (diff)
downloadrpm-90eec724a834c26131be11145a62084efe3bafb8.tar.gz
rpm-90eec724a834c26131be11145a62084efe3bafb8.tar.bz2
rpm-90eec724a834c26131be11145a62084efe3bafb8.zip
Don't use static buffer for parsing an expression
Diffstat (limited to 'build')
-rw-r--r--build/expression.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/build/expression.c b/build/expression.c
index df3307b8c..75ef4b917 100644
--- a/build/expression.c
+++ b/build/expression.c
@@ -257,40 +257,45 @@ static int rdToken(ParseState state)
default:
if (risdigit(*p)) {
- char temp[EXPRBUFSIZ], *t = temp;
+ char *temp;
+ size_t ts;
- temp[0] = '\0';
- while (*p && risdigit(*p))
- *t++ = *p++;
- *t++ = '\0';
- p--;
+ for (ts=1; p[ts] && risdigit(p[ts]); ts++);
+ temp = xmalloc(ts+1);
+ memcpy(temp, p, ts);
+ p += ts-1;
+ temp[ts] = '\0';
token = TOK_INTEGER;
v = valueMakeInteger(atoi(temp));
+ free(temp);
} else if (risalpha(*p)) {
- char temp[EXPRBUFSIZ], *t = temp;
+ char *temp;
+ size_t ts;
- temp[0] = '\0';
- while (*p && (risalnum(*p) || *p == '_'))
- *t++ = *p++;
- *t++ = '\0';
- p--;
+ for (ts=1; p[ts] && (risalpha(p[ts]) || p[ts] == '_'); ts++);
+ temp = xmalloc(ts+1);
+ memcpy(temp, p, ts);
+ p += ts-1;
+ temp[ts] = '\0';
token = TOK_IDENTIFIER;
- v = valueMakeString( xstrdup(temp) );
+ v = valueMakeString(temp);
} else if (*p == '\"') {
- char temp[EXPRBUFSIZ], *t = temp;
+ char *temp;
+ size_t ts;
- temp[0] = '\0';
- p++;
- while (*p && *p != '\"')
- *t++ = *p++;
- *t++ = '\0';
+ for (ts=1; p[ts] && p[ts] != '\"'; ts++);
+ temp = xmalloc(ts+1);
+ memcpy(temp, p, ts);
+ p += ts-1;
+ temp[ts] = '\0';
token = TOK_STRING;
v = valueMakeString( rpmExpand(temp, NULL) );
+ free(temp);
} else {
rpmlog(RPMLOG_ERR, _("parse error in expression\n"));