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);
|
uint8_t* data = malloc(statOfFile.st_size);
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
printf("Failure: malloc returns NULL");
|
return;
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t bytesRead =
|
size_t bytesRead =
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
#include "../lib/helper.h"
|
#include "../lib/helper.h"
|
||||||
#include "../lib/io.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
|
// +16 for the checksum
|
||||||
uint8_t* newBuf = calloc(len + 16, sizeof(uint8_t));
|
uint8_t* newBuf = calloc(len + 16, sizeof(uint8_t));
|
||||||
if (newBuf == NULL) {
|
if (newBuf == NULL) {
|
||||||
printf("Failure: calloc returns NULL");
|
return;
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
memcpy(newBuf, buf, len - paddingNeeded);
|
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 ===
|
// === step 3 ===
|
||||||
uint8_t* messageDigestBuf = calloc(48, sizeof(uint8_t));
|
uint8_t* messageDigestBuf = calloc(48, sizeof(uint8_t));
|
||||||
if (messageDigestBuf == NULL) {
|
if (messageDigestBuf == NULL) {
|
||||||
printf("Failure: calloc returns NULL");
|
return;
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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));
|
uint8_t* newBuf = aligned_alloc(16, sizeof(uint8_t)*(len + 16));
|
||||||
if (newBuf == NULL) {
|
if (newBuf == NULL) {
|
||||||
printf("Failure: aligned_alloc returns NULL");
|
return;
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0; i < 16; i++) {
|
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 ===
|
// === step 3 ===
|
||||||
uint8_t *messageDigestBuf = aligned_alloc(16, sizeof(uint8_t) * 48);
|
uint8_t *messageDigestBuf = aligned_alloc(16, sizeof(uint8_t) * 48);
|
||||||
if (messageDigestBuf == NULL) {
|
if (messageDigestBuf == NULL) {
|
||||||
printf("Failure: aligned_alloc returns NULL");
|
return;
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < 48; i++) {
|
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 ===
|
// === step 3 ===
|
||||||
uint8_t* messageDigestBuf = calloc(48, sizeof(uint8_t));
|
uint8_t* messageDigestBuf = calloc(48, sizeof(uint8_t));
|
||||||
if (messageDigestBuf == NULL) {
|
if (messageDigestBuf == NULL) {
|
||||||
printf("Failure: calloc returns NULL");
|
return;
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// === step 4 ===
|
// === step 4 ===
|
||||||
|
|
Loading…
Reference in a new issue