diff options
Diffstat (limited to 'src/sysdeps/trydevurandom.c')
-rw-r--r-- | src/sysdeps/trydevurandom.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/sysdeps/trydevurandom.c b/src/sysdeps/trydevurandom.c index 3d0f912..9c56e94 100644 --- a/src/sysdeps/trydevurandom.c +++ b/src/sysdeps/trydevurandom.c @@ -1,22 +1,11 @@ /* ISC license. */ +#include <string.h> #include <unistd.h> -#include <sys/types.h> #include <fcntl.h> +#include <sys/stat.h> -static int byte_diff (char *s, unsigned int n, char *t) -{ - for (;;) - { - if (!n) return 0 ; - if (*s != *t) break ; - ++s ; ++t ; --n ; - } - return ((int)(unsigned int)(unsigned char) *s) - - ((int)(unsigned int)(unsigned char) *t); -} - -int main () +int main (void) { char a[64] ; char b[64] ; @@ -27,5 +16,5 @@ int main () fd = open("/dev/urandom", O_RDONLY) ; if ((fd == -1) || (read(fd, b, 64) < 64) ) return 111 ; close(fd) ; - return (!byte_diff(a, 64, b)) ; + return (!memcmp(a, 64, b)) ; } |