Merge pull request #146 from danielinux/keytools-ioerrors

Fixed keytools error handling. Removed inclusion of target.h.
pull/149/head
David Garske 2021-09-07 09:14:35 -07:00 committed by GitHub
commit 0a2433a7a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View File

@ -7,11 +7,16 @@ ifeq ($(V),0)
Q=@
endif
ifeq ($(WOLFBOOT_SECTOR_SIZE),)
WOLFBOOT_SECTOR_SIZE=2048
endif
CC = gcc
WOLFBOOTDIR = ../..
WOLFDIR = $(WOLFBOOTDIR)/lib/wolfssl/
CFLAGS = -Wall -Wextra -Werror
CFLAGS += -I. -DWOLFSSL_USER_SETTINGS -I$(WOLFDIR) -I$(WOLFBOOTDIR)/include
CFLAGS += -DWOLFBOOT_SECTOR_SIZE=$(WOLFBOOT_SECTOR_SIZE)
# option variables
DEBUG_FLAGS = -g -DDEBUG -DDEBUG_SIGNTOOL -DDEBUG_WOLFSSL -DDEBUG_WOLFSSL_VERBOSE

View File

@ -39,8 +39,6 @@
#include <fcntl.h>
#include <stddef.h>
#include <unistd.h>
#include "target.h"
#include "delta.h"
#define MAX_SRC_SIZE (1 << 24)
@ -448,8 +446,9 @@ static int make_header_ex(int is_diff, uint8_t *pubkey, uint32_t pubkey_sz, cons
if (read_sz > 32)
read_sz = 32;
io_sz = fread(buf, 1, read_sz, f);
if (io_sz != (int)read_sz) {
ret = -1; break;
if ((io_sz < 0) && !feof(f)) {
ret = -1;
break;
}
ret = wc_Sha256Update(&sha, buf, read_sz);
pos += read_sz;
@ -493,8 +492,9 @@ static int make_header_ex(int is_diff, uint8_t *pubkey, uint32_t pubkey_sz, cons
if (read_sz > 128)
read_sz = 128;
io_sz = fread(buf, 1, read_sz, f);
if (io_sz != (int)read_sz) {
ret = -1; break;
if ((io_sz < 0) && !feof(f)) {
ret = -1;
break;
}
ret = wc_Sha3_384_Update(&sha, buf, read_sz);
pos += read_sz;
@ -866,8 +866,8 @@ static int base_diff(const char *f_base, uint8_t *pubkey, uint32_t pubkey_sz)
patch_inv_sz += r;
len3 += r;
} while (r > 0);
io_sz = ftruncate(fd3, len3);
if (io_sz != len3) {
ret = ftruncate(fd3, len3);
if (ret != 0) {
goto cleanup;
}
close(fd3);