Program: 175653
Project: 175653
Buggy source:
/** 
 * Derive key from a password using scrypt. <p> Excerpt from libsodium documentation: <blockquote> Scrypt was also designed to make it costly to perform large-scale custom hardware attacks by requiring large  amounts of memory. <p> Even though its memory hardness can be significantly reduced at the cost of extra computations, this function  remains an excellent choice today, provided that its parameters are properly chosen. </p> Scrypt is available in libsodium since version 0.5.0, which makes it a better choice than Argon2 if compatibility with older libsodium versions is a concern. </blockquote>
 * @param passwd Array of bytes of password
 * @param salt Salt to use in key generation. The salt should be unpredictable and can be generated by calling  {@link SodiumLibrary#randomBytes(int)}The salt should be saved by the caller as it will be needed to derive the key again from the  password.
 * @return key as an array of bytes
 * @throws SodiumLibraryException on error
 * @see <a href="https://download.libsodium.org/doc/password_hashing/" target="_blank">Password hashing</a>
 */
public static byte[] cryptoPwhashScrypt(byte[] passwd,byte[] salt) throws SodiumLibraryException {
  long salt_length=sodium().crypto_pwhash_scryptsalsa208sha256_saltbytes();
  if (salt.length != salt_length) {
    throw new SodiumLibraryException("String_Node_Str" + salt.length + "String_Node_Str"+ salt_length+ "String_Node_Str");
  }
  byte[] key=new byte[(int)sodium().crypto_box_seedbytes()];
  int rc=sodium().crypto_pwhash_scryptsalsa208sha256(key,key.length,passwd,passwd.length,salt,sodium().crypto_pwhash_opslimit_interactive(),sodium().crypto_pwhash_memlimit_interactive());
  logger.info("String_Node_Str" + rc);
  if (rc != 0) {
    throw new SodiumLibraryException("String_Node_Str" + rc + "String_Node_Str");
  }
  return key;
}

Fixed version (ground truth):
/** 
 * Derive key from a password using scrypt. <p> Excerpt from libsodium documentation: <blockquote> Scrypt was also designed to make it costly to perform large-scale custom hardware attacks by requiring large  amounts of memory. <p> Even though its memory hardness can be significantly reduced at the cost of extra computations, this function  remains an excellent choice today, provided that its parameters are properly chosen. </p> Scrypt is available in libsodium since version 0.5.0, which makes it a better choice than Argon2 if compatibility with older libsodium versions is a concern. </blockquote>
 * @param passwd Array of bytes of password
 * @param salt Salt to use in key generation. The salt should be unpredictable and can be generated by calling  {@link SodiumLibrary#randomBytes(int)}The salt should be saved by the caller as it will be needed to derive the key again from the  password.
 * @return key as an array of bytes
 * @throws SodiumLibraryException on error
 * @see <a href="https://download.libsodium.org/doc/password_hashing/" target="_blank">Password hashing</a>
 */
public static byte[] cryptoPwhashScrypt(byte[] passwd,byte[] salt) throws SodiumLibraryException {
  NativeLong salt_length=sodium().crypto_pwhash_scryptsalsa208sha256_saltbytes();
  if (salt.length != salt_length.intValue()) {
    throw new SodiumLibraryException("String_Node_Str" + salt.length + "String_Node_Str"+ salt_length+ "String_Node_Str");
  }
  byte[] key=new byte[sodium().crypto_box_seedbytes().intValue()];
  int rc=sodium().crypto_pwhash_scryptsalsa208sha256(key,key.length,passwd,passwd.length,salt,sodium().crypto_pwhash_opslimit_interactive(),sodium().crypto_pwhash_memlimit_interactive());
  logger.info("String_Node_Str" + rc);
  if (rc != 0) {
    throw new SodiumLibraryException("String_Node_Str" + rc + "String_Node_Str");
  }
  return key;
}