Skip to content

Conversation

@devnexen
Copy link
Member

No description provided.


blacklist->size += ZEND_BLACKLIST_BLOCK_SIZE;
blacklist->entries = (zend_blacklist_entry *) realloc(blacklist->entries, sizeof(zend_blacklist_entry)*blacklist->size);
zend_blacklist_entry * entries = (zend_blacklist_entry *) realloc(blacklist->entries, sizeof(zend_blacklist_entry) * blacklist->size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work on C89, as decls must be first in a block, sadly, Windows is one such case

}
b->length += 512;
b->data = realloc(b->data, b->length);
char *data = realloc(b->data, b->length);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment, decls first in block

return;
}
target->str = (char*)realloc(target->str, newsize);
char *str = (char*)realloc(target->str, newsize);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment, decls first in block

main/network.c Outdated
}
*hstbuflen *= 2;
*tmphstbuf = (char *)realloc (*tmphstbuf,*hstbuflen);
char *ptmphstbuf = (char *)realloc(*tmphstbuf, *hstbuflen);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment, decls first in block

main/network.c Outdated
}
*hstbuflen *= 2;
*tmphstbuf = (char *)realloc (*tmphstbuf,*hstbuflen);
char *ptmphstbuf = (char *)realloc(*tmphstbuf, *hstbuflen);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment, decls first in block

main/network.c Outdated
if (*hstbuflen < sizeof(struct hostent_data)) {
*hstbuflen = sizeof(struct hostent_data);
*tmphstbuf = (char *)realloc(*tmphstbuf, *hstbuflen);
char *ptmphstbuf = (char *)realloc(*tmphstbuf, *hstbuflen);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment, decls first in block

main/network.c Outdated
&& (errno == ERANGE)) {
char *ptmphstbuf;
/* Enlarge the buffer. */
if (*hstbuflen * 2 >= SIZE_MAX) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is always false. Should probably be *hstbuflen > SIZE_MAX / 2? (Same below)

@krakjoe
Copy link
Member

krakjoe commented Oct 20, 2016

Can I get an update on status here please ?

Should be rebased on 7.0, master is using zend MM in libxmlrpc.

p = pp;
return p;
}
free(p);
Copy link
Member

@nikic nikic Oct 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes aren't necessary -- zend_out_of_memory will exit anyway. We can't avoid "leaks" in that situation in any case (where leak = reachable memory).

@nikic
Copy link
Member

nikic commented Oct 20, 2016

I'm not a huge fan of checking alloc return values -- it makes the code pretty ugly to handle cases that are not really of practical relevance. I wonder if it wouldn't be better to replace something like

char *data = realloc(b->data, b->length);
if (!data) {
    buffer_delete(b);
    return;
}
b->data = data;

with

b->data = perealloc(b->data, b->length, 1);

perealloc in persistent mode goes through __zend_realloc, which is infallible, so we don't need to deal with the failure case. I'm seeing a bunch of places using pemalloc functions with a hardcoded 1 argument, so it seems like we already use this kind of pattern.

if (!pini_entries) {
goto out;
}
ini_entries = pini_entries;
Copy link
Member

@nikic nikic Oct 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the suggestion from #2162 (comment), this whole change (including the overflow check) could be written as:

ini_entries = safe_perealloc(ini_entries, ini_entries_len, 1, sizeof(HARDCODED_INI), 1);

perealloc handles the failure case, safe handles the overflow.

val++;
if (!isalnum(*val) && *val != '"' && *val != '\'' && *val != '\0') {
ini_entries = realloc(ini_entries, ini_entries_len + len + sizeof("\"\"\n\0"));
if ((ini_entries_len + len + sizeof("\"\"\n\0")) >= SIZE_MAX) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally all checks of the form >= SIZE_MAX are ineffective, because the overflow will already happen before the comparison.

@krakjoe
Copy link
Member

krakjoe commented Apr 3, 2017

I think this was superseded by work done by Nikita, so closing this PR.

@krakjoe krakjoe closed this Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants