|
|
@ -111,6 +111,9 @@ int rots_read_hdr(FILE *fp, struct rots_hdr *hdr) |
|
|
|
if (memcmp(magic, ROTS_MAGIC, 8) != 0) |
|
|
|
if (memcmp(magic, ROTS_MAGIC, 8) != 0) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (read_u64(fp, &hdr->timestamp) < sizeof hdr->timestamp) |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
if (read_u64(fp, &hdr->size) < sizeof hdr->size) |
|
|
|
if (read_u64(fp, &hdr->size) < sizeof hdr->size) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
@ -122,6 +125,9 @@ int rots_write_hdr(FILE *fp, struct rots_hdr *hdr) |
|
|
|
if (fwrite(ROTS_MAGIC, sizeof(char), 8, fp) < 8) |
|
|
|
if (fwrite(ROTS_MAGIC, sizeof(char), 8, fp) < 8) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (write_u64(fp, hdr->timestamp) < sizeof hdr->timestamp) |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
if (write_u64(fp, hdr->size) < sizeof hdr->size) |
|
|
|
if (write_u64(fp, hdr->size) < sizeof hdr->size) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
@ -150,6 +156,9 @@ int rots_read_sig_hdr(FILE *fp, struct rots_sig_hdr *sig_hdr) |
|
|
|
if (fread(sig_hdr->digest, sizeof *sig_hdr->digest, len, fp) < len) |
|
|
|
if (fread(sig_hdr->digest, sizeof *sig_hdr->digest, len, fp) < len) |
|
|
|
goto err_free_digest; |
|
|
|
goto err_free_digest; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (read_u64(fp, &sig_hdr->timestamp) < sizeof sig_hdr->timestamp) |
|
|
|
|
|
|
|
goto err_free_digest; |
|
|
|
|
|
|
|
|
|
|
|
if (read_u32(fp, &sig_hdr->size) < sizeof sig_hdr->size) |
|
|
|
if (read_u32(fp, &sig_hdr->size) < sizeof sig_hdr->size) |
|
|
|
goto err_free_digest; |
|
|
|
goto err_free_digest; |
|
|
|
|
|
|
|
|
|
|
@ -182,6 +191,9 @@ int rots_write_sig_hdr(FILE *fp, struct rots_sig_hdr *sig_hdr) |
|
|
|
if (fwrite(sig_hdr->digest, sizeof *sig_hdr->digest, len, fp) < len) |
|
|
|
if (fwrite(sig_hdr->digest, sizeof *sig_hdr->digest, len, fp) < len) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (write_u64(fp, sig_hdr->timestamp) < sizeof sig_hdr->timestamp) |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
if (write_u32(fp, sig_hdr->size) < sizeof sig_hdr->size) |
|
|
|
if (write_u32(fp, sig_hdr->size) < sizeof sig_hdr->size) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|