Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/tools/clu_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,11 +1305,10 @@ WOLFSSL_X509_NAME* wolfCLU_ParseX509NameString(const char* n, int nSz)
wolfCLU_LogError("error allocating name structure");
return NULL;
}

for (word = strtok_r((char*)n, deli, &end); word != NULL;
word = strtok_r(NULL, deli, &end)) {
tagSz = (int)strcspn(word, "=");
if (tagSz <= 0) {
if (tagSz <= 0 || word[tagSz] != '=') {
Comment thread
aidankeefe2022 marked this conversation as resolved.
wolfCLU_LogError("error finding '=' char in name");
wolfSSL_X509_NAME_free(ret);
ret = NULL;
Expand Down
8 changes: 6 additions & 2 deletions src/x509/clu_request_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,9 +865,13 @@ int wolfCLU_requestSetup(int argc, char** argv)
if (name != NULL) {
wolfSSL_X509_REQ_set_subject_name(x509, name);
wolfSSL_X509_NAME_free(name);
reSign = 1; /* re-sign after subject change */
}
else {
wolfCLU_LogError("Failed to parse -subj string");
wolfCLU_certgenHelp();
ret = USER_INPUT_ERROR;
}

reSign = 1; /* re-sign after subject change */
}

/* if no configure is passed in then get input from command line */
Expand Down
14 changes: 14 additions & 0 deletions tests/x509/x509-process-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,20 @@ def test_4f_nonexistent_file_pem(self):
self.assertNotEqual(r.returncode, 0)


class TestMalformedArguments(unittest.TestCase):
""" Regression: for malformed arguments """

def test_5a_malformed_subj_argument(self):
""" malformed string passed to -subj should result in error and
logging of issue """
r = run_wolfssl("req", "-new", "-days", "3650",
"-key", os.path.join(CERTS_DIR, "server-key.pem"),
"-subj",
"/O=wolfSSL/C=US/ST=WA/L=Seattle/CN=wolfSSL/OUorg-unit")
self.assertNotEqual(r.returncode, 0, r.stderr)
self.assertGreater(len(r.stderr), 0)


class TestX509ModulusNoout(unittest.TestCase):
"""Regression: x509 -modulus -noout must not crash."""

Expand Down
Loading