-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #23937 - fix rahash2 JSON ssdeep output ##json ##print #23938
Fix #23937 - fix rahash2 JSON ssdeep output ##json ##print #23938
Conversation
|
libr/main/rahash2.c
Outdated
@@ -147,7 +147,11 @@ static void do_hash_print(RHash *ctx, RahashOptions *ro, ut64 hash, int dlen, PJ | |||
case 'j': | |||
pj_o (pj); | |||
pj_ks (pj, "name", hname); | |||
do_hash_hexprint (c, dlen, ule, pj, rad); | |||
if (hash & R_HASH_SSDEEP) { | |||
pj_ks (pj, "hash", c); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would suggest to print the hash as an array of numbers or an hexpair string (that's probably more common representation) you can use the r_hex_bin2strdup
function which takes c and dlen and returns a heap allocated string that can be passed instead of c to the pjks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case..for ssdeep. this is actually a binary printable buffer.. so maybe asuming that its null terminated you can just cast it to (const char *)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup - found a similar cast elsewhere so figured that was an acceptable option. I was hoping to wake up this morning and make that code change but thanks for the assist!
Description
This should be a straight-forward code change to ensure
> rahash2 -a ssdeep -j /path/to/bin
actually prints the correctssdeep
hash as expected.This is my first PR. I believe I followed everything correctly and expect this to be good to go, but I'm happy to learn and make updates if needed. Specifically, I:
r2r
test suite. Everything finished and I didn't see my test throw an error but I was unclear on how to specifically confirm that my new test actually ran.I tracked some of my analysis to identify the fix on my personal fork here.