libkcapi/110-fipshmac-compat.patch

31 lines
1.2 KiB
Diff

diff -up libkcapi-1.1.5/apps/kcapi-hasher.c.fipshmac-compat libkcapi-1.1.5/apps/kcapi-hasher.c
--- libkcapi-1.1.5/apps/kcapi-hasher.c.fipshmac-compat 2019-01-23 07:14:51.000000000 +0100
+++ libkcapi-1.1.5/apps/kcapi-hasher.c 2020-04-23 14:37:59.518173594 +0200
@@ -386,10 +386,16 @@ static char *paste(char *dst, const char
static char *get_hmac_file(const char *filename, const char *checkdir)
{
size_t i, filelen, pathlen, namelen, basenamestart = 0;
- size_t prefixlen = strlen(CHECK_PREFIX);
+ const char *check_prefix = CHECK_PREFIX;
+ size_t prefixlen = strlen(check_prefix);
size_t suffixlen = strlen(CHECK_SUFFIX);
char *cursor, *checkfile = NULL;
+ if (prefixlen == 0 && checkdir == NULL) {
+ check_prefix = ".";
+ prefixlen = 1;
+ }
+
filelen = strlen(filename);
if (filelen > 4096) {
fprintf(stderr, "File too long\n");
@@ -415,7 +421,7 @@ static char *get_hmac_file(const char *f
} else if (pathlen > 0)
cursor = paste(cursor, filename, pathlen);
- cursor = paste(cursor, CHECK_PREFIX, prefixlen);
+ cursor = paste(cursor, check_prefix, prefixlen);
cursor = paste(cursor, filename + basenamestart, namelen);
cursor = paste(cursor, "."CHECK_SUFFIX, 1 + suffixlen);
strncpy(cursor, "\0", 1);