Skip to content

Commit 634598f

Browse files
committed
Guard Windows absolute-path check with explicit length check
The drive-letter branch indexed out[1] and out[2] relying on short-circuit evaluation of NUL-termination. Add an explicit outSz >= 3 length check before the indexing to avoid any potential out-of-bounds read that ASAN/UBSAN could flag.
1 parent 372ea2a commit 634598f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/x509/clu_x509_sign.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,11 +1049,14 @@ int wolfCLU_CertSignAppendOut(WOLFCLU_CERT_SIGN* csign, char* out)
10491049
int currentSz = (int)XSTRLEN(csign->outDir);
10501050

10511051
/* If out is an absolute path, use it directly instead of appending.
1052-
* Matches OpenSSL's ossl_is_absolute_path() behaviour. */
1052+
* Matches OpenSSL's ossl_is_absolute_path() behaviour. A drive-letter
1053+
* path (e.g. "C:\" or "C:/") requires at least 3 characters, so guard
1054+
* the indexing with an explicit length check. */
10531055
if (out[0] == '/'
10541056
#ifdef _WIN32
10551057
|| out[0] == '\\'
1056-
|| (isalpha((unsigned char)out[0]) && out[1] == ':'
1058+
|| (outSz >= 3 && isalpha((unsigned char)out[0])
1059+
&& out[1] == ':'
10571060
&& (out[2] == '\\' || out[2] == '/'))
10581061
#endif
10591062
) {

0 commit comments

Comments
 (0)