OSSP CVS Repository

ossp - Difference in ossp-pkg/uuid/uuid_prng.c versions 1.6 and 1.7
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/uuid/uuid_prng.c 1.6 -> 1.7

--- uuid_prng.c  2005/08/30 15:26:07     1.6
+++ uuid_prng.c  2005/08/30 18:41:56     1.7
@@ -63,7 +63,7 @@
     if ((fd = open("/dev/urandom", O_RDONLY)) == -1)
         fd = open("/dev/random", O_RDONLY|O_NONBLOCK);
     if (fd != -1) {
-        fcntl(fd, F_SETFD, FD_CLOEXEC);
+        (void)fcntl(fd, F_SETFD, FD_CLOEXEC);
         (*prng)->dev = fd;
     }
 
@@ -75,7 +75,7 @@
     (*prng)->cnt = 0;
 
     /* seed the C library PRNG once */
-    gettimeofday(&tv, NULL);
+    (void)gettimeofday(&tv, NULL);
     pid = getpid();
     srand((unsigned int)(
         ((unsigned int)pid << 16)
@@ -130,17 +130,19 @@
     /* approach 2: try to gather data via weaker libc PRNG API. */
     while (n > 0) {
         /* gather new entropy */
-        gettimeofday(&(entropy.tv), NULL);
+        (void)gettimeofday(&(entropy.tv), NULL);
         entropy.cnt = prng->cnt++;
         entropy.rnd = rand();
 
         /* pass entropy into MD5 engine */
-        md5_update(prng->md5, (void *)&entropy, sizeof(entropy));
+        if (md5_update(prng->md5, (void *)&entropy, sizeof(entropy)) != MD5_RC_OK)
+            return PRNG_RC_INT;
 
         /* store MD5 engine state as PRN output */
         md5_ptr = md5_buf;
         md5_len = sizeof(md5_buf);
-        md5_store(prng->md5, (void *)&md5_ptr, &md5_len);
+        if (md5_store(prng->md5, (void *)&md5_ptr, &md5_len) != MD5_RC_OK)
+            return PRNG_RC_INT;
         for (i = 0; i < MD5_LEN_BIN && n > 0; i++, n--)
             *p++ ^= md5_buf[i]; /* intentionally no assignment because arbitrary
                                    caller buffer content is leveraged, too */

CVSTrac 2.0.1