trendmicro / tlsh

Other
726 stars 135 forks source link

tlsh/tlsh.h has faulty definition of TLSH_STRING_BUFFER_LEN #114

Open mapreri opened 2 years ago

mapreri commented 2 years ago

Look at this trivial bit:

mattia@warren /tmp/foo1 % cat test.cxx
#include<tlsh/tlsh.h>

int main(){
    return TLSH_STRING_BUFFER_LEN;
}
mattia@warren /tmp/foo1 % c++ -Wall -Werror test.cxx -ltlsh  
In file included from test.cxx:1:
test.cxx: In function ‘int main()’:
test.cxx:4:12: error: ‘TLSH_STRING_LEN_REQ’ was not declared in this scope; did you mean ‘TLSH_STRING_BUFFER_LEN’?
    4 |     return TLSH_STRING_BUFFER_LEN;
      |            ^~~~~~~~~~~~~~~~~~~~~~
1 mattia@warren /tmp/foo1 %

that's because tlsh.h defines TLSH_STRING_BUFFER_LEN using TLSH_STRING_LEN_REQ as base, but this is not defined outside of the current tlsh build, since defining that relies on the presence of any of BUCKETS_(48|64|128) that during the build is done from cmake.

This is since 4.0.0 (commit dc3f047fbc3e78f587ed63c31cbe788acd9d1aac), when you changed the definition of TLSH_STRING_LEN_REQ to not have an else branch anymore.

What's supposed to happen now? Should "includers" of the library define BUCKETS_* somehow?