All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ima-evm-utils: Namespace some too generic function names
@ 2019-07-24 20:42 Vitaly Chikunov
  2019-07-24 21:46 ` Bruno E. O. Meneguele
  2019-07-24 23:24 ` Mimi Zohar
  0 siblings, 2 replies; 5+ messages in thread
From: Vitaly Chikunov @ 2019-07-24 20:42 UTC (permalink / raw)
  To: Mimi Zohar, Dmitry Kasatkin, linux-integrity

Prefix `dump', `do_dump', and `params' with `ima_' to avoid colliding
with other global symbols.

`params' is prefixed with a #define trick to avoid change in half
hundred places.

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
---

I think all other exported functions (good example is verify_hash) should be
prefixed too.

 src/evmctl.c    | 6 +++---
 src/imaevm.h    | 9 ++++++---
 src/libimaevm.c | 6 +++---
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/evmctl.c b/src/evmctl.c
index 3289061..b2e5af5 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -565,7 +565,7 @@ static int sign_evm(const char *file, const char *key)
 		sig[1] = 3; /* immutable signature version */
 
 	if (sigdump || params.verbose >= LOG_INFO)
-		dump(sig, len);
+		ima_dump(sig, len);
 
 	if (xattr) {
 		err = lsetxattr(file, xattr_evm, sig, len, 0);
@@ -604,7 +604,7 @@ static int hash_ima(const char *file)
 		log_info("hash: ");
 
 	if (sigdump || params.verbose >= LOG_INFO)
-		dump(hash, len);
+		ima_dump(hash, len);
 
 	if (xattr) {
 		err = lsetxattr(file, xattr_ima, hash, len, 0);
@@ -638,7 +638,7 @@ static int sign_ima(const char *file, const char *key)
 	sig[0] = EVM_IMA_XATTR_DIGSIG;
 
 	if (sigdump || params.verbose >= LOG_INFO)
-		dump(sig, len);
+		ima_dump(sig, len);
 
 	if (sigfile)
 		bin2file(file, "sig", sig, len);
diff --git a/src/imaevm.h b/src/imaevm.h
index 0414433..d00922c 100644
--- a/src/imaevm.h
+++ b/src/imaevm.h
@@ -49,9 +49,12 @@
 
 #include <openssl/rsa.h>
 
+/* Namespace some internal symbols */
+#define params		ima_params
+
 #ifdef USE_FPRINTF
 #define do_log(level, fmt, args...)	({ if (level <= params.verbose) fprintf(stderr, fmt, ##args); })
-#define do_log_dump(level, p, len, cr)	({ if (level <= params.verbose) do_dump(stderr, p, len, cr); })
+#define do_log_dump(level, p, len, cr)	({ if (level <= params.verbose) ima_do_dump(stderr, p, len, cr); })
 #else
 #define do_log(level, fmt, args...)	syslog(level, fmt, ##args)
 #define do_log_dump(level, p, len, cr)
@@ -206,8 +209,8 @@ struct RSA_ASN1_template {
 
 extern struct libevm_params params;
 
-void do_dump(FILE *fp, const void *ptr, int len, bool cr);
-void dump(const void *ptr, int len);
+void ima_do_dump(FILE *fp, const void *ptr, int len, bool cr);
+void ima_dump(const void *ptr, int len);
 int ima_calc_hash(const char *file, uint8_t *hash);
 int get_hash_algo(const char *algo);
 RSA *read_pub_key(const char *keyfile, int x509);
diff --git a/src/libimaevm.c b/src/libimaevm.c
index 2d99570..afa978f 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -89,7 +89,7 @@ struct libevm_params params = {
 
 static void __attribute__ ((constructor)) libinit(void);
 
-void do_dump(FILE *fp, const void *ptr, int len, bool cr)
+void ima_do_dump(FILE *fp, const void *ptr, int len, bool cr)
 {
 	int i;
 	uint8_t *data = (uint8_t *) ptr;
@@ -100,9 +100,9 @@ void do_dump(FILE *fp, const void *ptr, int len, bool cr)
 		fprintf(fp, "\n");
 }
 
-void dump(const void *ptr, int len)
+void ima_dump(const void *ptr, int len)
 {
-	do_dump(stdout, ptr, len, true);
+	ima_do_dump(stdout, ptr, len, true);
 }
 
 const char *get_hash_algo_by_id(int algo)
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-25 11:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-24 20:42 [PATCH] ima-evm-utils: Namespace some too generic function names Vitaly Chikunov
2019-07-24 21:46 ` Bruno E. O. Meneguele
2019-07-24 23:24 ` Mimi Zohar
2019-07-25  1:53   ` Vitaly Chikunov
2019-07-25 11:48     ` Mimi Zohar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.