feat: nullchecks updated
This commit is contained in:
parent
e516595eb2
commit
558f509281
5 changed files with 7 additions and 12 deletions
|
@ -35,8 +35,7 @@ uint8_t* read_file(const char* path, size_t* size) {
|
|||
|
||||
uint8_t* data = malloc(statOfFile.st_size);
|
||||
if (data == NULL) {
|
||||
printf("Failure: malloc returns NULL");
|
||||
return EXIT_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
size_t bytesRead =
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <stdbool.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include "../lib/helper.h"
|
||||
#include "../lib/io.h"
|
||||
|
|
|
@ -26,8 +26,7 @@ void md2_hash_0(size_t len, const uint8_t buf[len], uint8_t out[16]) {
|
|||
// +16 for the checksum
|
||||
uint8_t* newBuf = calloc(len + 16, sizeof(uint8_t));
|
||||
if (newBuf == NULL) {
|
||||
printf("Failure: calloc returns NULL");
|
||||
return EXIT_FAILURE;
|
||||
return;
|
||||
}
|
||||
memcpy(newBuf, buf, len - paddingNeeded);
|
||||
|
||||
|
@ -49,8 +48,7 @@ void md2_hash_0(size_t len, const uint8_t buf[len], uint8_t out[16]) {
|
|||
// === step 3 ===
|
||||
uint8_t* messageDigestBuf = calloc(48, sizeof(uint8_t));
|
||||
if (messageDigestBuf == NULL) {
|
||||
printf("Failure: calloc returns NULL");
|
||||
return EXIT_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,8 +47,7 @@ void md2_hash_1(size_t len, const uint8_t buf[len], uint8_t out[16])
|
|||
|
||||
uint8_t* newBuf = aligned_alloc(16, sizeof(uint8_t)*(len + 16));
|
||||
if (newBuf == NULL) {
|
||||
printf("Failure: aligned_alloc returns NULL");
|
||||
return EXIT_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < 16; i++) {
|
||||
|
@ -65,8 +64,7 @@ void md2_hash_1(size_t len, const uint8_t buf[len], uint8_t out[16])
|
|||
// === step 3 ===
|
||||
uint8_t *messageDigestBuf = aligned_alloc(16, sizeof(uint8_t) * 48);
|
||||
if (messageDigestBuf == NULL) {
|
||||
printf("Failure: aligned_alloc returns NULL");
|
||||
return EXIT_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 48; i++) {
|
||||
|
|
|
@ -51,8 +51,7 @@ void md2_hash_2(size_t len, const uint8_t buf[len], uint8_t out[16]) {
|
|||
// === step 3 ===
|
||||
uint8_t* messageDigestBuf = calloc(48, sizeof(uint8_t));
|
||||
if (messageDigestBuf == NULL) {
|
||||
printf("Failure: calloc returns NULL");
|
||||
return EXIT_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
// === step 4 ===
|
||||
|
|
Loading…
Reference in a new issue