[hackers] [sbase] Can't use sizeof on malloc'ed array in expr(1) || FRIGN
commit 50ecbd43ad6d85f27eae5251bac7c72e37d35b78
Author: FRIGN <dev_AT_frign.de>
Date: Mon Mar 23 22:31:36 2015 +0100
Can't use sizeof on malloc'ed array in expr(1)
Thanks emg for reporting this!
diff --git a/expr.c b/expr.c
index 31b3726..b166a02 100644
--- a/expr.c
+++ b/expr.c
_AT_@ -62,6 +62,7 @@ match(struct val *vstr, struct val *vregx, struct val *ret)
regex_t re;
regmatch_t matches[2];
long long d;
+ size_t anchlen;
char strbuf[maxdigits + 1], regxbuf[maxdigits + 1],
*s, *p, *anchreg, *str, *regx;
const char *errstr;
_AT_@ -81,9 +82,10 @@ match(struct val *vstr, struct val *vregx, struct val *ret)
}
/* anchored regex */
- anchreg = emalloc(strlen(regx) + 2);
- estrlcpy(anchreg, "^", sizeof(anchreg));
- estrlcat(anchreg, regx, sizeof(anchreg));
+ anchlen = strlen(regx) + 1 + 1;
+ anchreg = emalloc(anchlen);
+ estrlcpy(anchreg, "^", anchlen);
+ estrlcat(anchreg, regx, anchlen);
enregcomp(3, &re, anchreg, 0);
free(anchreg);
Received on Tue Mar 24 2015 - 23:54:21 CET
This archive was generated by hypermail 2.3.0
: Wed Mar 25 2015 - 00:11:54 CET