Skip to content

Commit

Permalink
fix(fuzz): pass buffered to readBinary funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
hulkoba committed Dec 18, 2023
1 parent 08cda81 commit afc0432
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions test/fuzz/readKeyBinary.js
Expand Up @@ -10,9 +10,9 @@ function ignoredError(error) {
* @param { Buffer } inputData
*/
export function fuzz (inputData) {
const binaryKey = new Uint8Array(`-----BEGIN PGP PRIVATE KEY BLOCK-----\n ${inputData.toString('base64')} -----END PGP PRIVATE KEY BLOCK-----`);

return readKey({ binaryKey })
const binaryKey = `-----BEGIN PGP PRIVATE KEY BLOCK-----\n\n${inputData.toString('base64')}\n-----END PGP PRIVATE KEY BLOCK-----`;
const bufferedKey = new Uint8Array(Buffer.from(binaryKey, 'utf8'));
return readKey({ binaryKey: bufferedKey })
.catch(error => {
if (error.message && !ignoredError(error)) {
throw error;
Expand Down
6 changes: 3 additions & 3 deletions test/fuzz/readMessageBinary.js
Expand Up @@ -10,9 +10,9 @@ function ignoredError(error) {
* @param { Buffer } inputData
*/
export function fuzz (inputData) {
const binaryMessage = new Uint8Array(`-----BEGIN PGP MESSAGE-----\n ${inputData.toString('base64')} -----END PGP MESSAGE-----`);

return readMessage({ binaryMessage })
const binaryMessage = `-----BEGIN PGP MESSAGE-----\n\n${inputData.toString('base64')}\n-----END PGP MESSAGE-----`;
const bufferedMessage = new Uint8Array(Buffer.from(binaryMessage, 'utf8'));
return readMessage({ binaryMessage: bufferedMessage })
.catch(error => {
if (error.message && !ignoredError(error)) {
throw error;
Expand Down

0 comments on commit afc0432

Please sign in to comment.