[PATCH] iscsi-iname: fix iscsi-iname -p access NULL pointer without given IQN prefix

10 views
Skip to first unread message

Wu Bo

unread,
Mar 18, 2020, 9:46:06 PM3/18/20
to Lee Duncan, Chris Leech, open-...@googlegroups.com, Mike Christie, mingfangsen
From: Wu Bo <wub...@huawei.com>

iscsi-iname -p access NULL pointer without give IQN prefix.

# iscsi-iname -p
Segmentation fault

Signed-off-by: Wu Bo <wub...@huawei.com>
---
 utils/iscsi-iname.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utils/iscsi-iname.c b/utils/iscsi-iname.c
index da850dc..7df7bb0 100644
--- a/utils/iscsi-iname.c
+++ b/utils/iscsi-iname.c
@@ -69,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 (prefix && (strnlen(prefix, PREFIX_MAX_LEN + 1) >
PREFIX_MAX_LEN)) {
                 printf("Error: Prefix cannot exceed %d "
                        "characters.\n", PREFIX_MAX_LEN);
                 exit(1);
--
2.21.0



The Lee-Man

unread,
Mar 25, 2020, 9:11:32 PM3/25/20
to open-iscsi
Thank you very much for this bug report and suggested patch, but I cleaned up the code and fixed it a little differently.
Reply all
Reply to author
Forward
0 new messages