Skip to content

Commit

Permalink
Added one more check in FileAppend pureChecks
Browse files Browse the repository at this point in the history
Signed-off-by: Kim Rader <kim.rader@swirldslabs.com>
  • Loading branch information
kimbor committed Nov 16, 2023
1 parent 4742555 commit 5994d96
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public void pureChecks(@NonNull final TransactionBody txn) throws PreCheckExcept
if (transactionBody.fileID() == null) {
throw new PreCheckException(INVALID_FILE_ID);
}
if (transactionBody.contents() == null || transactionBody.contents().length() == 0) {
throw new PreCheckException(FILE_CONTENT_EMPTY);
}
}

/**
Expand Down Expand Up @@ -108,11 +111,11 @@ public void handle(@NonNull final HandleContext handleContext) throws HandleExce
final var target = fileAppend.fileID();
final var data = fileAppend.contents();
final var fileServiceConfig = handleContext.configuration().getConfigData(FilesConfig.class);
if (data == null || data.length() <= 0) {
if (data == null || data.length() <= 0) { // should never happen, this is checked in pureChecks
logger.debug("FileAppend: No data to append");
}

if (target == null) {
if (target == null) { // should never happen, this is checked in pureChecks
throw new HandleException(INVALID_FILE_ID);
}

Expand Down

0 comments on commit 5994d96

Please sign in to comment.