Open AlekseyCherepanov opened 2 months ago
Thanks. I don't remember this stuff well enough to comment without reviewing the code first.
By ciphertext
, do you mean the char *source
argument?
Ouch! Yes, I meant the char *source
argument. Also I should copy-paste actual piece of code inserted in source()
in dynamic_fmt.c
: printf("%s\n", source);
.
creation of invalid pointer is undefined behaviour in C
It is not true on its own. Some ways to get an invalid pointer might be UB though, e.g. some_array - 1
(link).
I was working on a tracer for formats. It prints all arguments of methods. Particularly I tried to print
ciphertext
argument ofsource()
method. Wrappingfmt_default_source
caused stable crashes, so I checked sources and it was obvious that db is adjusted expecting that newsource()
would reconstruct ciphertext. I was adding my wrappers afterinit()
, so I assumed that the problem was that db was initialized with one configuration and used with other.So I tried to wrap only non-default
source()
and print ciphertext as regular string. It mostly worked but there was a crash late during--test=0
. Again it was ciphertext argument not pointing to memory. Also the crash was weird because test case could be reduced only to--format='HAVAL-128-4,hdaa,HMAC-SHA1,HMAC-SHA512,dynamic_0'
and nothing less (and even order was important).As far as I understand, john might or might not adjust db to remove ciphertexts. In any case, custom
source()
should usebinary
argument and ignoreciphertext
. Is that right?And there are 2 problems:
formats.h
(at least for me)The wording:
Let's remove my tracing code and add just
printf("%s\n", ciphertext);
intostatic char *source(...)
indynamic_fmt.c
. The crash repeats:printf("%s\n", ciphertext);
was optimized intoputs(ciphertext);
but we still can see the argument's value:0x ad5f187c ad5f187c
does not seem to be a pointer, alsogdb
says it cannot access memory there.formats.h
could be more explicit thatthe simplest case
should befmt_default_source
and it cannot be anything else.