>>> Chris Leech <cle...@redhat.com> schrieb am 13.06.2018 um 17:25 in Nachricht
<20180613152545.1049967-4-cle...@redhat.com>:
> errno must be set to 0 before calling strtoll or error checking will
> have false positives
> ---
>  libopeniscsiusr/sysfs.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libopeniscsiusr/sysfs.c b/libopeniscsiusr/sysfs.c
> index 6f295b702821..d312d4e299d0 100644
> --- a/libopeniscsiusr/sysfs.c
> +++ b/libopeniscsiusr/sysfs.c
> @@ -229,6 +229,7 @@ static int iscsi_sysfs_prop_get_ll(struct iscsi_context 
> *ctx,
>               }
>       }
>  
> +     errno = 0;
>       tmp_val = strtoll((const char *) buff, NULL, 10 /* base */);
>       errno_save = errno;
>       if ((errno_save != 0) && (! ignore_error)) {

Hi!

Relying on errno being set seems unreliable; a more reliable approach would use 
the return pointer (endptr) to check that there is no unprocessed rest. Thus 
the error condition would look like "if ( rest != NULL && rest[0] != '\0' )"...

Regards,
Ulrich

> -- 
> 2.14.4
> 
> -- 
> 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 post to this group, send email to open-iscsi@googlegroups.com.
> Visit this group at https://groups.google.com/group/open-iscsi.
> For more options, visit https://groups.google.com/d/optout.




-- 
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 post to this group, send email to open-iscsi@googlegroups.com.
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to