On 11/07/2012 12:17 AM, rahul wrote:
> Mike, 
> 
> 
>     Huh. Not sure what happened there. You are right. I made the attached
>     patch. Thanks for the bug report and thanks for following up!
> 
> 
>     diff --git a/usr/auth.c b/usr/auth.c
>     index c924545..52e9946 100644
>     --- a/usr/auth.c
>     +++ b/usr/auth.c
>     @@ -194,19 +194,19 @@ get_random_bytes(unsigned char *data, unsigned
>     int length)
>              fd = open("/dev/urandom", O_RDONLY);
>              while (length > 0) {
>      
>     -                if (!fd || read(fd, &r, sizeof(long)) != -1)
>     +                if (!fd || read(fd, &r, sizeof(long)) == -1)
>                              r = rand();
>                      r = r ^ (r >> 8);
>                      r = r ^ (r >> 4);
>                      n = r & 0x7;
>      
>     -                if (!fd || read(fd, &r, sizeof(long)) != -1)
>     +                if (!fd || read(fd, &r, sizeof(long)) == -1)
>                              r = rand();
>                      r = r ^ (r >> 8);
>                      r = r ^ (r >> 5);
>                      n = (n << 3) | (r & 0x7);
>      
>     -                if (!fd || read(fd, &r, sizeof(long)) != -1)
>     +                if (!fd || read(fd, &r, sizeof(long)) == -1)
>                              r = rand();
>                      r = r ^ (r >> 8);
>                      r = r ^ (r >> 5);
> 
> Thanks for taking a look at this and fixing this. I feel following check
> would be better. If open fails, it returns -1, so (!fd) is not correct.
> We should check for fd == -1.
> 
> if ( fd == -1 || read(fd, &r, sizeof(long)) != sizeof(long))
> 

You are very correct. I will fix that in the patch that gets merged. Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com.
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to