3

I have a diff:

diff --git openbsd-compat/arc4random.c openbsd-compat/arc4random.c
--- openbsd-compat/arc4random.c
+++ openbsd-compat/arc4random.c
@@ -242,7 +242,7 @@ void
 arc4random_buf(void *buf, size_t n)
 {
        _ARC4_LOCK();
-       _rs_random_buf(buf, n);
+       memset(buf, 0, n);
        _ARC4_UNLOCK();
 }
 # endif /* !HAVE_ARC4RANDOM_BUF */

But I don't understand, how exactly do I need to modify the:

https://github.com/openbsd/src/blob/master/lib/libc/crypt/arc4random.c

code to have the exact same as the diff.

Can someone please explain? Or am I looking at the wrong arc4random.c file? Just want to reduce randomness for testing purposes based on: http://www.vegardno.net/2017/03/fuzzing-openssh-daemon-using-afl.html

Hessnov
  • 367
  • 2
  • 7
  • I don't understand your question. It appears that the arc4random.c file is already modified. What are you trying to do here? – Code-Apprentice Apr 08 '18 at 19:36
  • [Detailed Description of Unified Format](https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html#Detailed-Unified) – max630 Apr 08 '18 at 19:56
  • It's a bit different (file's line do not contain timestamp, and hunk header has suffix which should help human readers to understand a function whre the change is), but the idea is simillar – max630 Apr 08 '18 at 19:58

1 Answers1

2

You would need to change the line 195, this is remove the line

-       _rs_random_buf(buf, n);

And add the line:

+       memset(buf, 0, n);

(in its place)

The line above and below the changed line are part of the context of the diff hunk. See more at "Unexpected result in git-diff". That would apply that patch manually to your version of src/arc4random.c.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • wow, thanks! but I am still confused why are there lines like: _ARC4_LOCK(); and _ARC4_UNLOCK(); etc. – Hessnov Apr 08 '18 at 19:50
  • @Hessnov They are part of the *context* of the diff *hunk. See more here: https://stackoverflow.com/a/40552165/6309 – VonC Apr 08 '18 at 19:51