-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: urcd
action: commit
revision:
path_from:
revision_from: c5dca8d93db6fbb11914d1fd75faefccb6d0a98c:
path_to:
revision_to:

git.thebackupbox.net

urcd

git://git.thebackupbox.net/urcd

commit c5dca8d93db6fbb11914d1fd75faefccb6d0a98c
Author: root <root@localhost.(none)>
Date:   Sun Dec 14 01:09:02 2014 +0000

    [liburc] randombytes use stack and heap (see comment)

diff --git a/src/liburc.h b/src/liburc.h

index a013dd212eaee19c1eb54974feb3f43fcd6647f4..

index ..b4a1e19a6d4435a7b2bb3285d78ce82aba303940 100644

--- a/src/liburc.h
+++ b/src/liburc.h
@@ -46,12 +46,14 @@ void randombytes(unsigned char *b, int blen) {
  if (devurandomfd == -1) devurandomfd = open("/dev/urandom",O_RDONLY);
  if (devurandomfd == -1) {
   unsigned char * a = malloc(256 * sizeof(unsigned char));
+  unsigned char c[256]; /* sometimes heap is zeroed, try luck with stack */
   struct timeval now;
   int i;
   for (i=0;i<blen;++i) {
    gettimeofday(&now,'\x00');
    srand(now.tv_usec);
    b[i] = rand() & 255;
+   b[i] ^= c[i & 255];
    if (a) b[i] ^= a[i & 255];
   }if (a) free(a);
  } else read(devurandomfd,b,blen);

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 18:23:17 2024