mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #2365] Missing memory wrapper mem_realloc() #1583
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#1583
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Dec 16, 2016).
Original GitHub issue: https://github.com/openwall/john/issues/2365
Originally assigned to: @magnumripper on GitHub.
Looking at the leaks in 'my' random tests, I noticed it is complaining about realloc().
Is it by design or a mistake?
@ghost commented on GitHub (Dec 16, 2016):
BTW: it also complains about a leak in path.c. The problem is that unless john proper uses something like the pseudo code below, any try to 'fix' the leak is much worse than the leak itself (we have to do a lot of copy/paste).
@magnumripper commented on GitHub (Dec 17, 2016):
What's the original warning/complaint in path.c? Is it some alloc we can turn into alloc_tiny?
@ghost commented on GitHub (Dec 17, 2016):
[edited]
Short: we call path_init() without calling path_done() => ONLY when a *2john is run.
Message:
@magnumripper commented on GitHub (Dec 18, 2016):
OK so it's a leak-once and then we exit anyway. We could fix it just to avoid seeing the complaint (we've done so with other things) but there's no other reason.
@magnumripper commented on GitHub (Dec 18, 2016):
So back to the original issue. We could/should add a mem_realloc with error checking a la mem_alloc but that "miss" itself should not be the problem here.
What are the complaints you see? What is missing? Under a memdbg build, it seems to me (at a quick glance just using grep) that memdbg.h defines realloc as macro pointing to MEMDBG_realloc. BTW things like that are the reasons the
#include "memdbg.h"must be the very last sourcing of headers.@ghost commented on GitHub (Dec 18, 2016):
Have you noticed the
#if !defined(__MEMDBG__)?@magnumripper commented on GitHub (Dec 18, 2016):
Yes but
__MEMDBG__is only defined when called from memdbg.c itself (do not confuse__MEMDBG__with eg.MEMDBG_ON)Edit: Perhaps we should refactor it to
__MEMDBG_C__@magnumripper commented on GitHub (Dec 18, 2016):
Ah, OK this is a normal leak-once. It not about realloc, it could have been alloc just as well. We never free Buf - we just let the OS do it for us.
@magnumripper commented on GitHub (Dec 18, 2016):
And that code is subject to change anyway, see https://github.com/magnumripper/JohnTheRipper/issues/2352#issuecomment-265020494
@ghost commented on GitHub (Dec 18, 2016):
It was about style or consistency: if I can't use malloc(), then I can't use realloc(). Indeed, it is not a "real leak". I'm being a nuisance.
I prefer:
__MEMDBG_C_FILE__@magnumripper commented on GitHub (Dec 19, 2016):
Agreed, we should add mem_realloc. In fact some of the realloc calls are much more likely to fail than any of the allocs. We have things like
if (size < needed) { size *= 2; buf = realloc(buf, size); }. So ensuring proper handling of errors (which is slightly more complicated for realloc than for alloc) is a good thing.