From 178f9c8751aac14582cce2ba741d26a0653b400c Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Mon, 3 Jan 2011 15:01:38 +1100 Subject: [PATCH] Only set CHAP username/password if BOTH have been provided. There is no point in setting the username if there is no password and vice versa. Also, if we only set username but not passwd this would lead to a segv. --- lib/init.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/init.c b/lib/init.c index 4d8a2a3..ec2c28f 100644 --- a/lib/init.c +++ b/lib/init.c @@ -345,7 +345,7 @@ iscsi_parse_full_url(struct iscsi_context *iscsi, const char *url) return NULL; } - if (user != NULL) { + if (user != NULL && passwd != NULL) { iscsi_url->user = strdup(user); if (iscsi_url->user == NULL) { iscsi_set_error(iscsi, "Out-of-memory: Failed to strdup username string"); @@ -353,9 +353,7 @@ iscsi_parse_full_url(struct iscsi_context *iscsi, const char *url) free(str); return NULL; } - } - - if (passwd != NULL) { + iscsi_url->passwd = strdup(passwd); if (iscsi_url->passwd == NULL) { iscsi_set_error(iscsi, "Out-of-memory: Failed to strdup password string");