tCheck signature len explicitely - sick - sign and check files using ed25519
(HTM) git clone git://z3bra.org/sick
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 6d05eb404c6e4b43d169c11d9bd0c59303d41e61
(DIR) parent 729b4c31f2073cde4f9a641d44e306543d12af2d
(HTM) Author: z3bra <willyatmailoodotorg>
Date: Tue, 13 Sep 2016 23:20:54 +0200
Check signature len explicitely
Diffstat:
M sick.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
---
(DIR) diff --git a/sick.c b/sick.c
t@@ -139,11 +139,8 @@ extractsig(unsigned char **sig, char *buf, size_t len)
/* search start and end strings for the signatures */
begin = memstr(buf, len, SIGBEGIN, strlen(SIGBEGIN)) + strlen(SIGBEGIN);
- if (!begin)
- return 0;
-
- end = memstr(begin, len, SIGEND, strlen(SIGEND));
- if (!end)
+ end = memstr(buf, len, SIGEND, strlen(SIGEND));
+ if (!(begin && end))
return 0;
/* ed25519 signatures are 64 bytes longs */
t@@ -177,7 +174,7 @@ extractsig(unsigned char **sig, char *buf, size_t len)
free(tmp);
}
- return len;
+ return siglen;
}
/*
t@@ -370,9 +367,9 @@ check(FILE *fp, FILE *key)
if (verbose)
fprintf(stderr, "Extracting signature from input\n");
- if (extractsig(&sig, buf, len) == 0) {
+ if (extractsig(&sig, buf, len) != 64) {
if (verbose)
- fprintf(stderr, "ERROR: No signature found\n");
+ fprintf(stderr, "ERROR: No valid signature found\n");
free(buf);
return ERR_NOSIG;