Conversation
|
This is part 1 of 2: it resolves points which were not initialized to NULL as part of I'm a bit uncertain as to how much detail you want in these commits, and there's a whole " |
|
This now includes initializing pointers in libarchive. |
|
We should NULL pointers when we're relying on them being NULL. In some cases we were implicitly assuming that memset(0) set pointers to NULL, but we shouldn't make that assumption. But there's no need to set all pointers to NULL unless there's some reason to think that it's going to matter (e.g. we're comparing against NULL or calling free on them later). And there's especially no point diverging from the upstream libarchive code to do that -- although if libarchive already has patches adding NULLification there's no harm in taking them. |
Right; those should be fixed. Should I document each one in the commit message? (and obviously remove ones where I can't identify a specific error) |
Yes please. |
archive_entry_link_resolver.c: we need res->spare to be NULL before we
call find_entry() or next_entry().
tree.c: if we call tree_open() and then tree_close(), we need t->buff to
be NULL.
Reported by: Ted Unangst
Bug bounty: $2
bsdtar.c:
- clarification: sort initializations in the same order as their
declaration in bsdtar.h.
matching.c:
- suppose we call inclusions() and then cleanup_exclusions().
inclusions() then calls initialize_matching() and then add_pattern()
which initializes matching->inclusions.
However, matching->exclusions was only initialized with a memset(),
so it might not be NULL when cleanup_exclusions() does
`p = bsdtar->matching->exclusions; while (p != NULL)`.
The same argument applies if we call exclusions() instead of
inclusions() at the beginning.
tree.c:
- t->stack: if we call tree_open() and then tree_close(), we need it
to be NULL for the `while (t->stack != NULL)`.
- t->d: if we call tree_open() and then tree_next(), we need it to be
NULL for the `while (t->d != NULL)`.
|
Revised with justifications in commit messages, and omitting the non-bounty |
No description provided.