janstarke / rexgen

API Documentation
https://github.com/janstarke/rexgen/blob/master/doc/api.md
GNU General Public License v2.0
52 stars 20 forks source link

Incompatible interface change in commit 15bd1082 #66

Closed frank-dittrich closed 3 years ago

frank-dittrich commented 4 years ago

Commit 15bd10821c000d7941f2b58db4c8dee13db924be (changed parser error handling) among other changes also changed the interface of c_regex_ptr in librexgen.h.

This breaks external applications using this library.

It would be nice to change interfaces only for new releases.

https://github.com/openwall/john uses librexgen when configured with rexgen support.

$ ./configure --enable-rexgen
[...]
 - librexgen (regex mode) .................. yes

To be able to build john with rexgen support, on top of https://github.com/janstarke/rexgen/pull/64 I had to apply the following change

diff --git a/src/librexgen/c/ApiContext.h b/src/librexgen/c/ApiContext.h
index 9885c7e..4c943e7 100644
--- a/src/librexgen/c/ApiContext.h
+++ b/src/librexgen/c/ApiContext.h
@@ -23,8 +23,8 @@
 typedef int c_regex_ptr;
 typedef int c_iterator_ptr;

-const c_regex_ptr c_regex_none = 0;
-const c_iterator_ptr c_iterator_none = 0;
+static const c_regex_ptr c_regex_none = 0;
+static const c_iterator_ptr c_iterator_none = 0;

 #ifdef __cplusplus
 #include <librexgen/regex/regex.h>

to avoid these build errors

/usr/bin/ld: inc.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: inc.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: john.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: john.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: options.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: options.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: recovery.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: recovery.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: wordlist.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: wordlist.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: mkv.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: mkv.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: listconf.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: listconf.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: regex.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: regex.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
/usr/bin/ld: pp.o:/usr/local/include/librexgen/c/ApiContext.h:27: multiple definition of `c_iterator_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:27: first defined here
/usr/bin/ld: pp.o:/usr/local/include/librexgen/c/ApiContext.h:26: multiple definition of `c_regex_none'; external.o:/usr/local/include/librexgen/c/ApiContext.h:26: first defined here
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:1450: ../run/john] Error 1
make[1]: Leaving directory '/home/fd/git/john/src'
make: *** [Makefile:190: default] Error 2

With these changes applied to rexgen, I was able to adjust John the Ripper to work with latest librexgen, see https://github.com/openwall/john/pull/4642