SHA256
1
0
forked from pool/tboot
Marcus Meissner 2012-05-31 12:00:13 +00:00 committed by Git OBS Bridge
parent aee759155e
commit 7de0996a1c

View File

@ -13,3 +13,56 @@ Index: tboot-1.7.0/lcptools/mlehash.c
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);