Chore: Fix compiler warnings
This commit is contained in:
parent
047ad315da
commit
61be4c0382
5 changed files with 7 additions and 6 deletions
|
@ -3,7 +3,7 @@
|
|||
SRC = src/main.c src/helper.c src/io.c src/md2.c src/md2_impls/md2_common.c src/md2_impls/md2_0.c
|
||||
OBJ = ${subst src,build,${SRC:.c=.o}}
|
||||
CC = gcc
|
||||
CFLAGS = -Ilib -ggdb -std=c11
|
||||
CFLAGS = -Ilib -ggdb -std=c11 -g -Wall -Wextra -no-pie -O3
|
||||
LDFLAGS =
|
||||
|
||||
all: md2
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef void (*md2_hash_func)(size_t len, const uint8_t buf[], uint8_t out[16]);
|
||||
typedef void (*md2_hash_func)(size_t len, const uint8_t buf[len],
|
||||
uint8_t out[16]);
|
||||
typedef void (*md2_checksum_func)(size_t len, uint8_t* buf);
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
void md2_hash_0(size_t len, const uint8_t buf[], uint8_t out[16]);
|
||||
void md2_hash_0(size_t len, const uint8_t buf[len], uint8_t out[16]);
|
||||
void md2_checksum_0(size_t len, uint8_t* buf);
|
||||
|
||||
#endif // MD2_0_H
|
|
@ -5,7 +5,7 @@
|
|||
void md2_checksum_0(size_t len, uint8_t* buf) {
|
||||
uint8_t l = 0;
|
||||
|
||||
for (int i = 0; i < len / 16; i++) {
|
||||
for (size_t i = 0; i < len / 16; i++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
u_int8_t c = buf[i * 16 + j];
|
||||
// reference is wrong. It says: Set C[j] to S[c xor L]. But it should be:
|
||||
|
@ -49,7 +49,7 @@ void md2_hash_0(size_t len, const uint8_t buf[len], uint8_t out[16]) {
|
|||
|
||||
// === step 4 ===
|
||||
// <= because we need to hash the last block too
|
||||
for (int i = 0; i <= (len + 16) / 16 - 1; i++) {
|
||||
for (size_t i = 0; i <= (len + 16) / 16 - 1; i++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
messageDigestBuf[16 + j] = newBuf[i * 16 + j];
|
||||
messageDigestBuf[32 + j] =
|
||||
|
|
|
@ -22,7 +22,7 @@ unsigned char MD2_PI_SUBST[256] = {
|
|||
20};
|
||||
|
||||
void md2_print_buf(size_t len, uint8_t buf[len]) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
printf("'%02x',", buf[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
|
Loading…
Reference in a new issue