Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sat, 11 May 2013 19:55:25 +0400
From: Alexander Cherepanov <cherepan@...me.ru>
To: john-dev@...ts.openwall.com
Subject: Unused global symbols in core

Hi, Solar!

There are unused global symbols in JtR. Here is the analysis for the core:

1. Easy to fix:
crk_remove_hash                 cracker.o <- cracker.c:135

2. Easy to fix:
DES_KS_table                    DES_std.o

3. Not used but supposed to be used (described in .h)?
itoa64                          common.o <- common.c:11

4. Not used but supposed to be used (described in .h)?
fmt_default_valid               formats.o <- formats.c:257
fmt_default_binary              formats.o <- formats.c:267

5. The following are described in rules.h but should they really be 
exported?
rules_errno                     rules.o
rules_line                      rules.o
rules_errors                    rules.o <- rules.c:20
rules_check                     rules.o <- rules.c:959

6. Not used in JtR itself but used in best.c:
benchmark_cps                   bench.o <- bench.c:211
benchmark_format                bench.o <- bench.c:87

7. Ok, the following should be non-static:-)
main                            john.o <- john.c:649

Attached are patches for the first 5 cases (selftests passed). First 
seems to be a sure target, but it's harder to tell for others -- maybe 
they are supposed to be that way.

-- 
Alexander Cherepanov

>From 044fcdd56a0583d48608486e310c2903c0737f19 Mon Sep 17 00:00:00 2001
From: Alexander Cherepanov <cherepan@...me.ru>
Date: Sat, 11 May 2013 18:11:48 +0400
Subject: [PATCH 1/5] Make crk_remove_hash() in cracker.c static.

---
 src/cracker.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/cracker.c b/src/cracker.c
index 46a0e19..a8ad77f 100644
--- a/src/cracker.c
+++ b/src/cracker.c
@@ -132,7 +132,7 @@ static void crk_remove_salt(struct db_salt *salt)
 /*
  * Updates the database after a password has been cracked.
  */
-void crk_remove_hash(struct db_salt *salt, struct db_password *pw)
+static void crk_remove_hash(struct db_salt *salt, struct db_password *pw)
 {
 	struct db_password **current;
 	int hash, count;
-- 
1.7.2.5


>From e0c3be4240ae0c3069fd68d4d20e768fd420a8c4 Mon Sep 17 00:00:00 2001
From: Alexander Cherepanov <cherepan@...me.ru>
Date: Sat, 11 May 2013 18:13:53 +0400
Subject: [PATCH 2/5] Make DES_KS_table in DES_std.c static.

---
 src/DES_std.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/DES_std.c b/src/DES_std.c
index 49de74b..126db57 100644
--- a/src/DES_std.c
+++ b/src/DES_std.c
@@ -83,7 +83,11 @@ DES_binary DES_IV;
 ARCH_WORD DES_count;
 
 DES_KS CC_CACHE_ALIGN DES_KS_current;
-DES_KS CC_CACHE_ALIGN DES_KS_table[8][128];
+static DES_KS CC_CACHE_ALIGN DES_KS_table[8][128];
+
+#else
+
+extern DES_KS DES_KS_table[8][128];
 
 #endif
 
@@ -97,8 +101,6 @@ extern DES_KS DES_KS_copy;
 unsigned ARCH_WORD *DES_out;
 #endif
 
-extern DES_KS DES_KS_table[8][128];
-
 #if ARCH_BITS >= 64
 static ARCH_WORD DES_IP_E[8][16], DES_C_FP[16][16];
 #else
-- 
1.7.2.5


>From 45c6d36a069e7fe12cd5b13a3b7018171d2fbf5a Mon Sep 17 00:00:00 2001
From: Alexander Cherepanov <cherepan@...me.ru>
Date: Sat, 11 May 2013 18:15:07 +0400
Subject: [PATCH 3/5] Make itoa64 in common.c static.

---
 src/common.c |    2 +-
 src/common.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/common.c b/src/common.c
index 0815ec5..721dfcf 100644
--- a/src/common.c
+++ b/src/common.c
@@ -8,7 +8,7 @@
 #include "arch.h"
 #include "common.h"
 
-char itoa64[64] =
+static char itoa64[64] =
 	"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 char atoi64[0x100];
 
diff --git a/src/common.h b/src/common.h
index a29e228..df46fe8 100644
--- a/src/common.h
+++ b/src/common.h
@@ -51,7 +51,7 @@ typedef unsigned int ARCH_WORD_32;
 /*
  * ASCII <-> binary conversion tables.
  */
-extern char itoa64[64], atoi64[0x100];
+extern char atoi64[0x100];
 extern char itoa16[16], atoi16[0x100];
 
 /*
-- 
1.7.2.5


>From 8043193af41c3a0a2942be8222764ce74cdeaad7 Mon Sep 17 00:00:00 2001
From: Alexander Cherepanov <cherepan@...me.ru>
Date: Sat, 11 May 2013 18:16:20 +0400
Subject: [PATCH 4/5] Comment out fmt_default_valid() and fmt_default_binary().

---
 src/formats.c |    4 ++++
 src/formats.h |    4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/formats.c b/src/formats.c
index e8e4b21..c65023a 100644
--- a/src/formats.c
+++ b/src/formats.c
@@ -254,20 +254,24 @@ char *fmt_default_prepare(char *fields[10], struct fmt_main *self)
 	return fields[1];
 }
 
+/*
 int fmt_default_valid(char *ciphertext, struct fmt_main *self)
 {
 	return 0;
 }
+*/
 
 char *fmt_default_split(char *ciphertext, int index, struct fmt_main *self)
 {
 	return ciphertext;
 }
 
+/*
 void *fmt_default_binary(char *ciphertext)
 {
 	return ciphertext;
 }
+*/
 
 void *fmt_default_salt(char *ciphertext)
 {
diff --git a/src/formats.h b/src/formats.h
index fe4682d..1a051ea 100644
--- a/src/formats.h
+++ b/src/formats.h
@@ -270,10 +270,10 @@ extern void fmt_default_init(struct fmt_main *self);
 extern void fmt_default_done(void);
 extern void fmt_default_reset(struct db_main *db);
 extern char *fmt_default_prepare(char *fields[10], struct fmt_main *self);
-extern int fmt_default_valid(char *ciphertext, struct fmt_main *self);
+/* extern int fmt_default_valid(char *ciphertext, struct fmt_main *self); */
 extern char *fmt_default_split(char *ciphertext, int index,
     struct fmt_main *self);
-extern void *fmt_default_binary(char *ciphertext);
+/* extern void *fmt_default_binary(char *ciphertext); */
 extern void *fmt_default_salt(char *ciphertext);
 extern char *fmt_default_source(char *source, void *binary);
 extern int fmt_default_binary_hash(void *binary);
-- 
1.7.2.5


>From a582da6cf337a6c636603103647ec158ed5763af Mon Sep 17 00:00:00 2001
From: Alexander Cherepanov <cherepan@...me.ru>
Date: Sat, 11 May 2013 18:18:12 +0400
Subject: [PATCH 5/5] Don't export various symbols in rules.[ch].

---
 src/rules.c |   25 ++++++++++++++++++++++---
 src/rules.h |   25 -------------------------
 2 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/src/rules.c b/src/rules.c
index dc3ac6e..251cceb 100644
--- a/src/rules.c
+++ b/src/rules.c
@@ -17,7 +17,10 @@
 #include "rpp.h"
 #include "rules.h"
 
-char *rules_errors[] = {
+/*
+ * Error names.
+ */
+static char *rules_errors[] = {
 	NULL,	/* No error */
 	"Unexpected end of rule",
 	"Unknown command",
@@ -27,7 +30,16 @@ char *rules_errors[] = {
 	"Unknown rule reject flag"
 };
 
-int rules_errno, rules_line;
+/*
+ * Last error code.
+ */
+static int rules_errno;
+
+/*
+ * Configuration file line number, only set after a rules_check() call if
+ * rules_errno indicates an error.
+ */
+static int rules_line;
 
 static int rules_max_length = 0;
 
@@ -956,7 +968,14 @@ out_ERROR_UNALLOWED:
 	goto out_NULL;
 }
 
-int rules_check(struct rpp_context *start, int split)
+/*
+ * Checks if all the rules for context are valid. Returns the number of rules,
+ * or returns zero and sets rules_errno on error.
+ *
+ * split == 0	"single crack" mode rules allowed
+ * split < 0	"single crack" mode rules are invalid
+ */
+static int rules_check(struct rpp_context *start, int split)
 {
 	struct rpp_context ctx;
 	char *rule;
diff --git a/src/rules.h b/src/rules.h
index 309724b..f2d9d8e 100644
--- a/src/rules.h
+++ b/src/rules.h
@@ -25,22 +25,6 @@
 #define RULES_ERROR_REJECT		6
 
 /*
- * Error names.
- */
-extern char *rules_errors[];
-
-/*
- * Last error code.
- */
-extern int rules_errno;
-
-/*
- * Configuration file line number, only set after a rules_check() call if
- * rules_errno indicates an error.
- */
-extern int rules_line;
-
-/*
  * Initializes the rules support.
  */
 extern void rules_init(int max_length);
@@ -76,15 +60,6 @@ extern char *rules_reject(char *rule, int split, char *last,
 extern char *rules_apply(char *word, char *rule, int split, char *last);
 
 /*
- * Checks if all the rules for context are valid. Returns the number of rules,
- * or returns zero and sets rules_errno on error.
- *
- * split == 0	"single crack" mode rules allowed
- * split < 0	"single crack" mode rules are invalid
- */
-extern int rules_check(struct rpp_context *start, int split);
-
-/*
  * Similar to rules_check(), but displays a message and does not return on
  * error.
  */
-- 
1.7.2.5


Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ