aboutsummaryrefslogtreecommitdiffstats
path: root/src/pdf_writer.c
diff options
context:
space:
mode:
authoryzrh <yzrh@noema.org>2023-01-01 10:44:27 +0000
committeryzrh <yzrh@noema.org>2023-01-01 11:11:56 +0000
commit9019a184494e6fc220bcc1eb8f47f33fe0f3e506 (patch)
tree1615ce42fec0e7e84d86178f08ae6fc2b55ccb7c /src/pdf_writer.c
parenta18de8f2ef4be4a92b2e08161ce4b8f164ad4f7f (diff)
downloadmelon-9019a184494e6fc220bcc1eb8f47f33fe0f3e506.tar.gz
melon-9019a184494e6fc220bcc1eb8f47f33fe0f3e506.tar.zst
Split md5 function.
Signed-off-by: yzrh <yzrh@noema.org>
Diffstat (limited to 'src/pdf_writer.c')
-rw-r--r--src/pdf_writer.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/pdf_writer.c b/src/pdf_writer.c
index be64e49..465d26b 100644
--- a/src/pdf_writer.c
+++ b/src/pdf_writer.c
@@ -5,11 +5,9 @@
*/
#include <stdlib.h>
-#include <string.h>
#include <time.h>
-#include <openssl/md5.h>
-
+#include "md5.h"
#include "pdf.h"
int
@@ -144,11 +142,11 @@ pdf_dump_trailer(pdf_object_t **pdf, FILE **fp, int xref)
buf_size = snprintf(buf, 64, "%lx%x", timestamp, size);
#endif
- unsigned char str[64];
- memcpy(str, buf, 64);
+ int fid_size;
+ unsigned char *fid;
- unsigned char fid[MD5_DIGEST_LENGTH];
- MD5(str, buf_size, fid);
+ if (strmd5(&fid, &fid_size, (unsigned char *) buf, buf_size) != 0)
+ return 1;
pdf_object_t *ptr = *pdf;
while (ptr->next != NULL)
@@ -172,7 +170,7 @@ pdf_dump_trailer(pdf_object_t **pdf, FILE **fp, int xref)
for (int i = 0; i < 2; i++) {
fputs("<", *fp);
- for (int j = 0; j < MD5_DIGEST_LENGTH; j++)
+ for (int j = 0; j < fid_size; j++)
fprintf(*fp, "%02x", fid[j]);
fputs(">", *fp);
@@ -191,5 +189,7 @@ pdf_dump_trailer(pdf_object_t **pdf, FILE **fp, int xref)
fputs("%%EOF\n", *fp);
+ free(fid);
+
return 0;
}