Search code examples
gitsshdfuzzing

Git diff explanation for sshd


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


Solution

  • 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.