Skip to content

Commit

Permalink
Ensure we do not ignore the return value for a write
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishcoleman committed Dec 11, 2024
1 parent 71d4e5c commit 99ffa5e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tools/crypto_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ static void cmd_header_decrypt (int argc, char **argv, void *conf) {
exit(1);
}

write(1, &buf, size);
int r = write(1, &buf, size);
if(r != size) {
printf("Short write\n");
}
exit(0);

}
Expand Down Expand Up @@ -130,7 +133,10 @@ static void cmd_pearson_128 (int argc, char **argv, void *conf) {
unsigned char hash[16];
size = read(0, &buf, sizeof(buf));
pearson_hash_128(hash, buf, size);
write(1, &hash, sizeof(hash));
int r = write(1, &hash, sizeof(hash));
if(r != sizeof(hash)) {
printf("Short write\n");
}
exit(0);
}

Expand Down

0 comments on commit 99ffa5e

Please sign in to comment.