Re: [PATCH V3 13/18] multipath: make reservation_key print out correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Acked-by: Vijay Chauhan <vijay.chauhan@xxxxxxxxxx>

Thanks,
Vijay

On January 12, 2013 11:35 AM; Benjamin Marzinski wrote:
>
>This patch fixes the reservation_key print functions, so they print
>it out like it was in the configuration file.  Also, it keeps
>cli_getprstatus() from writing over random memory.
>
>Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
>---
> libmultipath/dict.c       | 31 +++++++++++++++++++++++++++++--
> multipathd/cli_handlers.c |  2 +-
> 2 files changed, 30 insertions(+), 3 deletions(-)
>
>diff --git a/libmultipath/dict.c b/libmultipath/dict.c
>index 788ffae..a54dda9 100644
>--- a/libmultipath/dict.c
>+++ b/libmultipath/dict.c
>@@ -2052,8 +2052,22 @@ snprint_mp_prio_args(char * buff, int len, void *
>data)
> static int
> snprint_mp_reservation_key (char * buff, int len, void * data)
> {
>+	int i;
>+	unsigned char *keyp;
>+	uint64_t prkey = 0;
> 	struct mpentry * mpe = (struct mpentry *)data;
>-	return snprintf(buff, len, "%s" , mpe->reservation_key);
>+
>+	if (!mpe->reservation_key)
>+		return 0;
>+	keyp = (unsigned char *)mpe->reservation_key;
>+	for (i = 0; i < 8; i++) {
>+		if (i > 0)
>+			prkey <<= 8;
>+		prkey |= *keyp;
>+		keyp++;
>+	}
>+
>+	return snprintf(buff, len, "0x%" PRIx64, prkey);
> }
>
> 	static int
>@@ -2721,7 +2735,20 @@ snprint_def_wwids_file (char * buff, int len, void *
>data)
> static int
> snprint_def_reservation_key(char * buff, int len, void * data)
> {
>-	return snprintf(buff, len, "%s", conf->reservation_key);
>+	int i;
>+	unsigned char *keyp;
>+	uint64_t prkey = 0;
>+
>+	if (!conf->reservation_key)
>+		return 0;
>+	keyp = (unsigned char *)conf->reservation_key;
>+	for (i = 0; i < 8; i++) {
>+		if (i > 0)
>+			prkey <<= 8;
>+		prkey |= *keyp;
>+		keyp++;
>+	}
>+	return snprintf(buff, len, "0x%" PRIx64, prkey);
> }
>
> static int
>diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
>index 6053b5a..4df37fe 100644
>--- a/multipathd/cli_handlers.c
>+++ b/multipathd/cli_handlers.c
>@@ -947,7 +947,7 @@ cli_getprstatus (void * v, char ** reply, int * len,
>void * data)
>
>
> 	sprintf(*reply,"%d",mpp->prflag);
>-	*reply[1]='\0';
>+	(*reply)[1]='\0';
>
>
> 	condlog(3, "%s: reply = %s", param, *reply);
>--
>1.8.0
>
>--
>dm-devel mailing list
>dm-devel@xxxxxxxxxx
>https://www.redhat.com/mailman/listinfo/dm-devel

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel


[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux