Skip to content

Commit 9fa32e6

Browse files
schwabecron2
authored andcommitted
Ensure that get_sigtype always return non-NULL
There is a theoretical possibility that OpenSSL returns an NID that OBJ_nid2sn cannot resolve and thus the function return NULL. This is however extremely unlikely. But we still cover this case now to make linters/code checker happy and avoid similar false positives in the future. Reported-by: Joshua Rogers <[email protected]> Found-by: ZeroPath (https://zeropath.com/) Change-Id: I70e221ff5d9752fec17bad18fd41dcf188ae8fbc Signed-off-by: Arne Schwabe <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1325 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg34060.html Signed-off-by: Gert Doering <[email protected]>
1 parent d7f86dd commit 9fa32e6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/openvpn/ssl_openssl.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2408,7 +2408,17 @@ get_sigtype(int nid)
24082408
return "(error getting name)";
24092409

24102410
default:
2411-
return OBJ_nid2sn(nid);
2411+
{
2412+
const char *type = OBJ_nid2sn(nid);
2413+
if (!type)
2414+
{
2415+
/* This is unlikely to ever happen as OpenSSL is unlikely to
2416+
* return an NID it cannot resolve itself but we silence
2417+
* linter/code checkers here */
2418+
type = "(error getting name, OBJ_nid2sn failed)";
2419+
}
2420+
return type;
2421+
}
24122422
}
24132423
}
24142424
#endif /* ifndef LIBRESSL_VERSION_NUMBER */

0 commit comments

Comments
 (0)