detect-tls: check return values of functions on setup

Check the return values of DetectBufferSetActiveList() and
DetectSignatureSetAppProto().
pull/3868/head
Mats Klepsland 6 years ago committed by Victor Julien
parent 1c04d7cdae
commit 0f7f35bd85

@ -111,13 +111,15 @@ void DetectTlsFingerprintRegister(void)
* \param str Should hold an empty string always * \param str Should hold an empty string always
* *
* \retval 0 On success * \retval 0 On success
* \retval -1 On failure
*/ */
static int DetectTlsFingerprintSetup(DetectEngineCtx *de_ctx, Signature *s, static int DetectTlsFingerprintSetup(DetectEngineCtx *de_ctx, Signature *s,
const char *str) const char *str)
{ {
DetectBufferSetActiveList(s, g_tls_cert_fingerprint_buffer_id); if (DetectBufferSetActiveList(s, g_tls_cert_fingerprint_buffer_id) < 0)
return -1;
if (DetectSignatureSetAppProto(s, ALPROTO_TLS) != 0) if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
return -1; return -1;
return 0; return 0;

@ -102,11 +102,16 @@ void DetectTlsIssuerRegister(void)
* \param str Should hold an empty string always * \param str Should hold an empty string always
* *
* \retval 0 On success * \retval 0 On success
* \retval -1 On failure
*/ */
static int DetectTlsIssuerSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) static int DetectTlsIssuerSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{ {
DetectBufferSetActiveList(s, g_tls_cert_issuer_buffer_id); if (DetectBufferSetActiveList(s, g_tls_cert_issuer_buffer_id) < 0)
s->alproto = ALPROTO_TLS; return -1;
if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
return -1;
return 0; return 0;
} }

@ -111,12 +111,14 @@ void DetectTlsSerialRegister(void)
* \param str Should hold an empty string always * \param str Should hold an empty string always
* *
* \retval 0 On success * \retval 0 On success
* \retval -1 On failure
*/ */
static int DetectTlsSerialSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) static int DetectTlsSerialSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{ {
DetectBufferSetActiveList(s, g_tls_cert_serial_buffer_id); if (DetectBufferSetActiveList(s, g_tls_cert_serial_buffer_id) < 0)
return -1;
if (DetectSignatureSetAppProto(s, ALPROTO_TLS) != 0) if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
return -1; return -1;
return 0; return 0;

@ -101,11 +101,16 @@ void DetectTlsSubjectRegister(void)
* \param str Should hold an empty string always * \param str Should hold an empty string always
* *
* \retval 0 On success * \retval 0 On success
* \retval -1 On failure
*/ */
static int DetectTlsSubjectSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) static int DetectTlsSubjectSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{ {
DetectBufferSetActiveList(s, g_tls_cert_subject_buffer_id); if (DetectBufferSetActiveList(s, g_tls_cert_subject_buffer_id) < 0)
s->alproto = ALPROTO_TLS; return -1;
if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
return -1;
return 0; return 0;
} }

@ -112,11 +112,15 @@ void DetectTlsJa3HashRegister(void)
* \param str Should hold an empty string always * \param str Should hold an empty string always
* *
* \retval 0 On success * \retval 0 On success
* \retval -1 On failure
*/ */
static int DetectTlsJa3HashSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) static int DetectTlsJa3HashSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{ {
DetectBufferSetActiveList(s, g_tls_ja3_hash_buffer_id); if (DetectBufferSetActiveList(s, g_tls_ja3_hash_buffer_id) < 0)
s->alproto = ALPROTO_TLS; return -1;
if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
return -1;
if (RunmodeIsUnittests()) if (RunmodeIsUnittests())
return 0; return 0;

@ -102,11 +102,15 @@ void DetectTlsJa3StringRegister(void)
* \param str Should hold an empty string always * \param str Should hold an empty string always
* *
* \retval 0 On success * \retval 0 On success
* \retval -1 On failure
*/ */
static int DetectTlsJa3StringSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) static int DetectTlsJa3StringSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{ {
DetectBufferSetActiveList(s, g_tls_ja3_str_buffer_id); if (DetectBufferSetActiveList(s, g_tls_ja3_str_buffer_id) < 0)
s->alproto = ALPROTO_TLS; return -1;
if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
return -1;
if (RunmodeIsUnittests()) if (RunmodeIsUnittests())
return 0; return 0;

@ -100,11 +100,16 @@ void DetectTlsSniRegister(void)
* \param str Should hold an empty string always * \param str Should hold an empty string always
* *
* \retval 0 On success * \retval 0 On success
* \retval -1 On failure
*/ */
static int DetectTlsSniSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str) static int DetectTlsSniSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
{ {
DetectBufferSetActiveList(s, g_tls_sni_buffer_id); if (DetectBufferSetActiveList(s, g_tls_sni_buffer_id) < 0)
s->alproto = ALPROTO_TLS; return -1;
if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
return -1;
return 0; return 0;
} }

Loading…
Cancel
Save