Chore: Fix compiler warnings

This commit is contained in:
Dorian Zedler 2022-07-06 20:35:27 +02:00
parent 047ad315da
commit 61be4c0382
Signed by: dorian
GPG key ID: 989DE36109AFA354
5 changed files with 7 additions and 6 deletions

View file

@ -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 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}} OBJ = ${subst src,build,${SRC:.c=.o}}
CC = gcc CC = gcc
CFLAGS = -Ilib -ggdb -std=c11 CFLAGS = -Ilib -ggdb -std=c11 -g -Wall -Wextra -no-pie -O3
LDFLAGS = LDFLAGS =
all: md2 all: md2

View file

@ -8,7 +8,8 @@
#include <string.h> #include <string.h>
#include <sys/types.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); typedef void (*md2_checksum_func)(size_t len, uint8_t* buf);
/** /**

View file

@ -8,7 +8,7 @@
#include <string.h> #include <string.h>
#include <sys/types.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); void md2_checksum_0(size_t len, uint8_t* buf);
#endif // MD2_0_H #endif // MD2_0_H

View file

@ -5,7 +5,7 @@
void md2_checksum_0(size_t len, uint8_t* buf) { void md2_checksum_0(size_t len, uint8_t* buf) {
uint8_t l = 0; 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++) { for (int j = 0; j < 16; j++) {
u_int8_t c = buf[i * 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: // 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 === // === step 4 ===
// <= because we need to hash the last block too // <= 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++) { for (int j = 0; j < 16; j++) {
messageDigestBuf[16 + j] = newBuf[i * 16 + j]; messageDigestBuf[16 + j] = newBuf[i * 16 + j];
messageDigestBuf[32 + j] = messageDigestBuf[32 + j] =

View file

@ -22,7 +22,7 @@ unsigned char MD2_PI_SUBST[256] = {
20}; 20};
void md2_print_buf(size_t len, uint8_t buf[len]) { 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("'%02x',", buf[i]);
} }
printf("\n"); printf("\n");