~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/lib/crypto/prng.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman, Russ Allbery, Sam Hartman
  • Date: 2008-08-21 10:41:41 UTC
  • mfrom: (11.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080821104141-a0f9c4o4cpo8xd0o
Tags: 1.6.dfsg.4~beta1-4
[ Russ Allbery ]
* Translation updates:
  - Swedish, thanks Martin Bagge.  (Closes: #487669, #491774)
  - Italian, thanks Luca Monducci.  (Closes: #493962)

[ Sam Hartman ]
* Translation Updates:
    - Dutch, Thanks Vincent Zweije, Closes: #495733

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
  krb5_data data;
163
163
  struct stat sb;
164
164
  int fd;
165
 
  unsigned char buf[YARROW_SLOW_THRESH/8];
 
165
  unsigned char buf[YARROW_SLOW_THRESH/8], *bp;
166
166
  int left;
167
167
  fd = open (device, O_RDONLY);
168
168
  if (fd == -1)
173
173
    close(fd);
174
174
    return 0;
175
175
  }
176
 
  for (left = sizeof (buf); left > 0;) {
 
176
 
 
177
  for (bp = &buf, left = sizeof (buf); left > 0;) {
177
178
    ssize_t count;
178
 
    count = read (fd, &buf, (unsigned) left);
 
179
    count = read (fd, bp, (unsigned) left);
179
180
    if (count <= 0) {
180
181
      close(fd);
181
182
      return 0;
182
183
    }
183
184
    left -= count;
 
185
    bp += count;
184
186
  }
185
187
  close (fd);
186
188
  data.length = sizeof (buf);
199
201
  int unused;
200
202
  int *oursuccess = success?success:&unused;
201
203
  *oursuccess = 0;
202
 
  /* If we are getting strong data then try that first.  We aare
 
204
  /* If we are getting strong data then try that first.  We are
203
205
     guaranteed to cause a reseed of some kind if strong is true and
204
206
     we have both /dev/random and /dev/urandom.  We want the strong
205
207
     data included in the reseed so we get it first.*/