]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
fix some bugs in the fuzzer
authorDamien Miller <djm@mindrot.org>
Sun, 29 May 2022 23:29:09 +0000 (09:29 +1000)
committerDamien Miller <djm@mindrot.org>
Sun, 29 May 2022 23:29:20 +0000 (09:29 +1000)
regress/misc/fuzz-harness/authkeys_fuzz.cc

index 6fe001facb4358c75158fd200e9f1372c988e102..8b3e54e543d813bc4dc4156809879fc4765e9113 100644 (file)
@@ -49,9 +49,14 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
        }
        if (cp == NULL || pw == NULL || key == NULL || cert == NULL)
                abort();
+
+       // Cleanup whitespace at input EOL.
+       for (; size > 0 && strchr(" \t\r\n", data[size - 1]) != NULL; size--) ;
+
+       // Append a pubkey that will match.
        memcpy(cp, data, size);
        cp[size] = ' ';
-       memcpy(cp + size + 1, key, strlen(pubkey) + 1);
+       memcpy(cp + size + 1, pubkey, strlen(pubkey) + 1);
 
        // Try key.
        if ((tmp = strdup(cp)) == NULL)