forked from pool/tboot
OBS-URL: https://build.opensuse.org/package/show/security/tboot?expand=0&rev=15
69 lines
2.0 KiB
Diff
69 lines
2.0 KiB
Diff
Index: tboot-1.7.0/lcptools/mlehash.c
|
|
===================================================================
|
|
--- tboot-1.7.0.orig/lcptools/mlehash.c
|
|
+++ tboot-1.7.0/lcptools/mlehash.c
|
|
@@ -233,8 +233,8 @@ static void print_dump(uint32_t s, uint3
|
|
*/
|
|
static bool read_file(const char *filename, void **buffer, size_t *length)
|
|
{
|
|
- FILE *fcompressed = NULL;
|
|
- FILE *fdecompressed = NULL;
|
|
+ gzFile fcompressed = NULL;
|
|
+ FILE *fdecompressed = NULL;
|
|
struct stat filestat;
|
|
char tmpbuffer[1024];
|
|
unsigned long i;
|
|
Index: tboot-1.7.0/tb_polgen/commands.c
|
|
===================================================================
|
|
--- tboot-1.7.0.orig/tb_polgen/commands.c
|
|
+++ tboot-1.7.0/tb_polgen/commands.c
|
|
@@ -54,26 +54,31 @@ extern tb_policy_t *g_policy;
|
|
static bool hash_file(const char *filename, bool unzip, tb_hash_t *hash)
|
|
{
|
|
FILE *f;
|
|
+ gzFile gf;
|
|
static char buf[1024];
|
|
EVP_MD_CTX ctx;
|
|
const EVP_MD *md;
|
|
int read_cnt;
|
|
|
|
- if ( unzip )
|
|
- f = gzopen(filename, "rb");
|
|
- else
|
|
+ if ( unzip ) {
|
|
+ gf = gzopen(filename, "rb");
|
|
+ if ( gf == NULL ) {
|
|
+ error_msg("File %s does not exist\n", filename);
|
|
+ return false;
|
|
+ }
|
|
+ } else {
|
|
f = fopen(filename, "rb");
|
|
-
|
|
- if ( f == NULL ) {
|
|
- error_msg("File %s does not exist\n", filename);
|
|
- return false;
|
|
+ if ( f == NULL ) {
|
|
+ error_msg("File %s does not exist\n", filename);
|
|
+ return false;
|
|
+ }
|
|
}
|
|
|
|
md = EVP_sha1();
|
|
EVP_DigestInit(&ctx, md);
|
|
do {
|
|
if ( unzip )
|
|
- read_cnt = gzread(f, buf, sizeof(buf));
|
|
+ read_cnt = gzread(gf, buf, sizeof(buf));
|
|
else
|
|
read_cnt = fread(buf, 1, sizeof(buf), f);
|
|
if ( read_cnt == 0 )
|
|
@@ -84,7 +89,7 @@ static bool hash_file(const char *filena
|
|
EVP_DigestFinal(&ctx, hash->sha1, NULL);
|
|
|
|
if ( unzip )
|
|
- gzclose(f);
|
|
+ gzclose(gf);
|
|
else
|
|
fclose(f);
|
|
|