Fix bugs with memory allocation in ego.
cf/cf_loop.c and share/put.c tried to read the next pointer in an element of a linked list after freeing the element. ud/ud_copy.c tried to read beyond the end of the _defs_ array: it only has _nrexpldefs_ elements, not _nrdefs_ elements. These bugs caused core dumps on OpenBSD. Its malloc() put _defs_ near the end of a page, so reading beyond the end crossed into an unmapped page. Its free() wrote junk bytes and changed the next pointer to 0xdfdfdfdfdfdfdfdf.
This commit is contained in:
@@ -59,7 +59,7 @@ STATIC traverse_defs(p,action)
|
||||
def_to_copynr = newtable(nrdefs);
|
||||
cnt = 1;
|
||||
}
|
||||
if (defcnt > nrdefs) return;
|
||||
if (defcnt > nrexpldefs) return;
|
||||
for (b = p->p_start; b != (bblock_p) 0; b = b->b_next) {
|
||||
for (l = b->b_start; l != (line_p) 0; l = l->l_next) {
|
||||
if (defs[defcnt] == l) {
|
||||
@@ -75,7 +75,7 @@ STATIC traverse_defs(p,action)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (++defcnt > nrdefs) return;
|
||||
if (++defcnt > nrexpldefs) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user