msgbuf: s_assert is not a substitute for proper code

(dns, m_alias, m_stats updated as msgbuf no longer includes s_assert.h)
This commit is contained in:
Simon Arlott 2017-07-26 19:18:08 +01:00
parent d2b3a2a474
commit 169a1c3535
No known key found for this signature in database
GPG key ID: C8975F2043CA5D24
4 changed files with 25 additions and 14 deletions

View file

@ -19,8 +19,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "s_assert.h"
#ifndef CHARYBDIS__MSGBUF_H
#define CHARYBDIS__MSGBUF_H
@ -80,21 +78,21 @@ msgbuf_init(struct MsgBuf *msgbuf)
static inline void
msgbuf_append_tag(struct MsgBuf *msgbuf, const char *key, const char *value, unsigned int capmask)
{
s_assert(msgbuf->n_tags < MAXPARA);
msgbuf->tags[msgbuf->n_tags].key = key;
msgbuf->tags[msgbuf->n_tags].value = value;
msgbuf->tags[msgbuf->n_tags].capmask = capmask;
msgbuf->n_tags++;
if (msgbuf->n_tags < MAXPARA) {
msgbuf->tags[msgbuf->n_tags].key = key;
msgbuf->tags[msgbuf->n_tags].value = value;
msgbuf->tags[msgbuf->n_tags].capmask = capmask;
msgbuf->n_tags++;
}
}
static inline void
msgbuf_append_para(struct MsgBuf *msgbuf, const char *para)
{
s_assert(msgbuf->n_para < MAXPARA);
msgbuf->para[msgbuf->n_para] = para;
msgbuf->n_para++;
if (msgbuf->n_para < MAXPARA) {
msgbuf->para[msgbuf->n_para] = para;
msgbuf->n_para++;
}
}
#endif

View file

@ -36,6 +36,7 @@
#include "numeric.h"
#include "msg.h"
#include "hash.h"
#include "s_assert.h"
#define DNS_HOST_IPV4 ((char)'4')
#define DNS_HOST_IPV6 ((char)'6')
@ -82,7 +83,7 @@ handle_dns_failure(uint32_t xid)
struct dnsreq *req = rb_dictionary_retrieve(query_dict, RB_UINT_TO_POINTER(xid));
s_assert(req);
if(req->callback == NULL)
if(req == NULL || req->callback == NULL)
return;
req->callback("FAILED", 0, 0, req->data);
@ -96,7 +97,7 @@ handle_dns_stat_failure(uint32_t xid)
struct dnsstatreq *req = rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(xid));
s_assert(req);
if(req->callback == NULL)
if(req == NULL || req->callback == NULL)
return;
req->callback(1, NULL, 2, req->data);
@ -110,6 +111,10 @@ cancel_lookup(uint32_t xid)
{
struct dnsreq *req = rb_dictionary_retrieve(query_dict, RB_UINT_TO_POINTER(xid));
s_assert(req);
if (req == NULL)
return;
req->callback = NULL;
req->data = NULL;
}
@ -119,6 +124,10 @@ cancel_dns_stats(uint32_t xid)
{
struct dnsstatreq *req = rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(xid));
s_assert(req);
if (req == NULL)
return;
req->callback = NULL;
req->data = NULL;
}
@ -245,6 +254,8 @@ dns_stats_results_callback(const char *callid, const char *status, int resc, con
req = rb_dictionary_retrieve(stat_dict, RB_UINT_TO_POINTER(qid));
s_assert(req);
if (req == NULL)
return;
if(req->callback == NULL)
{

View file

@ -31,6 +31,7 @@
#include "numeric.h"
#include "send.h"
#include "packet.h"
#include "s_assert.h"
static const char alias_desc[] = "Provides the system for services aliases";

View file

@ -46,6 +46,7 @@
#include "whowas.h"
#include "rb_radixtree.h"
#include "sslproc.h"
#include "s_assert.h"
static const char stats_desc[] =
"Provides the STATS command to inspect various server/network information";