Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Possible NULL deref in cfp_matcher_range?
- X-seq: zsh-workers 35691
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Possible NULL deref in cfp_matcher_range?
- Date: Sun, 5 Jul 2015 16:52:19 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=vjpO4Zjv+KphSyFF9wjmtvlPll++oNeM7sAd/fOxx4A=; b=WRPC4x2RF9NitBAUAuRD1RYRON2VV5WJHSNWjGwXniw6XnNszyV9JJfgFqzT/e5jz4 2XZYpx59Q3LB19IhwxPA4mkSSQfPyLHkPQwwsZQn753I79px1W9VXj0Vr+LyocKZxs5q /aAbXDng19FwxBDR6emgwZ5OrPO4tmtMqlaLR6zfHus8wY3QjvnAkZV1VTe2aSrh5DNz 0lObUQZq8l+oH4rFUBBAB2/WspouYOnVRYbKDj8bcjoCICBKbRFdK+gffTfx0JbxeeBT qs07/h64TxT/UPwnmRyWTHomK2pRiGuYq1V7D0YVG4KnJKo+ljPI+fLwvqxXu848i1Nr 9lug==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Checking some stuff with clang, and it complained here;
static char *
cfp_matcher_range(Cmatcher *ms, char *add)
{
Cmatcher *mp, m;
int len = 0, mt;
char *ret = NULL, *p = NULL, *adds = add;
/*
* Do this twice: once to work out the length of the
* string in len, the second time to build it in ret.
* This is probably worthwhile because otherwise memory
* management is difficult.
*/
for (;;) {
MB_METACHARINIT();
for (mp = ms; *add; ) {
convchar_t addc;
int addlen;
addlen = MB_METACHARLENCONV(add, &addc);
#ifdef MULTIBYTE_SUPPORT
if (addc == WEOF)
addc = (wchar_t)(*p == Meta ? p[1] ^ 32 : *p);
#endif
First run through this code p is NULL, and the other places all (at
least the ones I looked at) protect accesses to p by "if (ret)" (which
is set at the same time as p). Should this do that, and/or do
something clever with len at the same time? Is there any way to
actually trigger addc to be WEOF here? Presumably if it is WEOF on the
second run when is set, then it was also WEOF the first time.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author