Browse code

bb#11421 - CUD digital signature verification and empty files

Kevin Lin authored on 2015/10/30 06:44:43
Showing 1 changed files
... ...
@@ -133,7 +133,6 @@ static int cli_untgz(int fd, const char *destdir)
133 133
 		    cli_untgz_cleanup(path, infile, outfile, fdd);
134 134
 		    return -1;
135 135
 	    }
136
-	    in_block = 1;
137 136
 
138 137
 	    if(outfile) {
139 138
 		if(fclose(outfile)) {
... ...
@@ -160,6 +159,9 @@ static int cli_untgz(int fd, const char *destdir)
160 160
 		return -1;
161 161
 	    }
162 162
 
163
+	    if (size > 0)
164
+		in_block = 1;
165
+
163 166
 	} else { /* write or continue writing file contents */
164 167
 	    nbytes = size > TAR_BLOCKSIZE ? TAR_BLOCKSIZE : size;
165 168
 	    nwritten = fwrite(block, 1, nbytes, outfile);
... ...
@@ -572,7 +574,7 @@ int cl_cvdverify(const char *file)
572 572
 {
573 573
 	struct cl_engine *engine;
574 574
 	FILE *fs;
575
-	int ret;
575
+	int ret, dbtype = 0;
576 576
 
577 577
 
578 578
     if((fs = fopen(file, "rb")) == NULL) {
... ...
@@ -587,7 +589,12 @@ int cl_cvdverify(const char *file)
587 587
     }
588 588
     engine->cb_stats_submit = NULL; /* Don't submit stats if we're just verifying a CVD */
589 589
 
590
-    ret = cli_cvdload(fs, engine, NULL, CL_DB_STDOPT | CL_DB_PUA, !!cli_strbcasestr(file, ".cld"), file, 1);
590
+    if (!!cli_strbcasestr(file, ".cld"))
591
+	dbtype = 1;
592
+    else if (!!cli_strbcasestr(file, ".cud"))
593
+	dbtype = 2;
594
+
595
+    ret = cli_cvdload(fs, engine, NULL, CL_DB_STDOPT | CL_DB_PUA, dbtype, file, 1);
591 596
 
592 597
     cl_engine_free(engine);
593 598
     fclose(fs);