open-iscsi/0040-iscsi-iname-remove-unneeded-temp-buffer.patch

57 lines
1.5 KiB
Diff
Raw Normal View History

2020-05-12 17:27:41 +08:00
From ed9621a9330c542e73c4290de76644b48e4d5113 Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Tue, 12 May 2020 15:50:09 +0800
Subject: [PATCH] iscsi-iname remove unneeded temp buffer
iscsi-iname remove unneeded temp buffer
Signed-off-by: Chris Leech <cleech@redhat.com>
---
utils/iscsi-iname.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/utils/iscsi-iname.c b/utils/iscsi-iname.c
index da8e68a..086d9bb 100644
--- a/utils/iscsi-iname.c
+++ b/utils/iscsi-iname.c
@@ -43,7 +43,6 @@
int
main(int argc, char *argv[])
{
- char iname[256];
struct timeval time;
struct utsname system_info;
long hostid;
@@ -56,7 +55,6 @@ main(int argc, char *argv[])
char *prefix;
/* initialize */
- memset(iname, 0, sizeof (iname));
memset(digest, 0, sizeof (digest));
memset(&context, 0, sizeof (context));
MD5Init(&context);
@@ -71,7 +69,7 @@ main(int argc, char *argv[])
exit(0);
} else if ( strcmp(prefix, "-p") == 0 ) {
prefix = argv[2];
- if (strnlen(prefix, PREFIX_MAX_LEN + 1) > PREFIX_MAX_LEN) {
+ if (strnlen(prefix, PREFIX_MAX_LEN + 1) > PREFIX_MAX_LEN) {
printf("Error: Prexfix cannot exceed %d "
"characters.\n", PREFIX_MAX_LEN);
}
@@ -140,10 +138,8 @@ main(int argc, char *argv[])
}
/* print the prefix followed by 6 bytes of the MD5 hash */
- sprintf(iname, "%s:%x%x%x%x%x%x", prefix,
+ printf("%s:%x%x%x%x%x%x", prefix,
bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5]);
- iname[sizeof (iname) - 1] = '\0';
- printf("%s\n", iname);
return 0;
}
--
1.8.3.1