Thank you very much for this bug report and suggested patch, but I cleaned 
up the code and fixed it a little differently.

On Wednesday, March 18, 2020 at 6:46:06 PM UTC-7, wubo40 wrote:
>
> 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 
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/c6cb350a-f8d2-486b-888c-dfc6e5b69a79%40googlegroups.com.

Reply via email to