Skip to content

Commit e43bb6a

Browse files
committed
fix f-1483 sha1 prefix substring matching
1 parent ad115fa commit e43bb6a

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/hash/clu_hash.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ int wolfCLU_hash(WOLFSSL_BIO* bioIn, WOLFSSL_BIO* bioOut, const char* alg,
121121
}
122122
#endif
123123
#ifndef NO_SHA
124-
if (ret == WOLFCLU_SUCCESS && XSTRNCMP(alg, "sha", 3) == 0) {
124+
if (ret == WOLFCLU_SUCCESS && XSTRNCMP(alg, "sha", 3) == 0
125+
&& XSTRLEN(alg) == 3) {
125126
ret = wc_ShaHash(input, inputSz, output);
126127
}
127128
#endif

src/hash/clu_hash_setup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ int wolfCLU_hashSetup(int argc, char** argv)
8181

8282
for (i = 0; i < (int)algsSz; ++i) {
8383
/* checks for acceptable algorithms */
84-
if (XSTRNCMP(argv[2], algs[i], XSTRLEN(algs[i])) == 0) {
84+
if (XSTRCMP(argv[2], algs[i]) == 0) {
8585
alg = argv[2];
8686
algCheck = 1;
8787
}
@@ -140,7 +140,7 @@ int wolfCLU_hashSetup(int argc, char** argv)
140140
#endif
141141

142142
#ifndef NO_SHA
143-
if (XSTRNCMP(alg, "sha", 3) == 0)
143+
if ((XSTRNCMP(alg, "sha", 3) == 0) && (XSTRLEN(alg) == 3))
144144
size = WC_SHA_DIGEST_SIZE;
145145
#endif
146146

0 commit comments

Comments
 (0)