On 11/07/2012 01:48 AM, Ulrich Windl wrote: >>>> rahul <junky_fel...@yahoo.co.in> schrieb am 07.11.2012 um 07:17 in >>>> Nachricht > <102cd120-1e96-4e71-9c41-eeaeb8675...@googlegroups.com>: >> 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) > > Hi! > > Sorry for jumping on this train: > > Isn't the proper test for a failed read "read(fd, &r, sizeof(long)) != > sizeof(long))"? >
It is late :) You are saying the same thing as rahul below right? > Ulrich > >>> 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 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.