diff options
Diffstat (limited to 'daemon/misc.c')
-rw-r--r-- | daemon/misc.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/daemon/misc.c b/daemon/misc.c index b585d8b..c3f5ff4 100644 --- a/daemon/misc.c +++ b/daemon/misc.c @@ -25,6 +25,8 @@ void ha_messagex(int level, const char* msg, ...) va_list ap; va_start(ap, msg); + ASSERT(msg); + /* Either to syslog or stderr */ if(g_daemonized) vsyslog(level, msg, ap); @@ -43,6 +45,8 @@ void ha_message(int level, const char* msg, ...) va_list ap; va_start(ap, msg); + ASSERT(msg); + /* Either to syslog or stderr */ if(g_daemonized) { @@ -75,6 +79,8 @@ ha_header_t* ha_findheader(ha_request_t* req, const char* name) { int i; + ASSERT(req && name); + for(i = 0; i < MAX_HEADERS; i++) { if(req->headers[i].name) @@ -91,6 +97,8 @@ const char* ha_getheader(ha_request_t* req, const char* name, const char* prefix { int i, l; + ASSERT(req && name); + for(i = 0; i < MAX_HEADERS; i++) { if(req->headers[i].name) @@ -114,6 +122,9 @@ const char* ha_getheader(ha_request_t* req, const char* name, const char* prefix void ha_addheader(ha_response_t* resp, const char* name, const char* data) { int i = 0; + + ASSERT(resp && name && data); + for(i = 0; i < MAX_HEADERS; i++) { if(!(resp->headers[i].name)) @@ -159,6 +170,8 @@ void ha_unlock(pthread_mutex_t* mtx) int ha_confbool(const char* name, const char* conf, int* value) { + ASSERT(name && conf && value); + if(value == NULL || value[0] == 0 || strcasecmp(conf, "0") == 0 || @@ -188,6 +201,10 @@ int ha_confbool(const char* name, const char* conf, int* value) int ha_confint(const char* name, const char* conf, int min, int max, int* value) { char* p; + + ASSERT(name && conf && value); + ASSERT(min <= max); + errno = 0; *value = strtol(conf, &p, 10); @@ -208,6 +225,8 @@ int ha_confint(const char* name, const char* conf, int min, int max, int* value) char* ha_uriformat(ha_buffer_t* buf, const ha_uri_t* uri) { + ASSERT(buf && uri); + /* This creates a new block */ ha_bufcpy(buf, ""); @@ -269,6 +288,8 @@ int ha_uriparse(ha_buffer_t* buf, const char* suri, ha_uri_t* uri) int port; int v6_offset1 = 0; + ASSERT(buf && suri && uri); + /* Copy the memory */ str = ha_bufcpy(buf, suri); @@ -502,6 +523,8 @@ int ha_uricmp(ha_uri_t* one, ha_uri_t* two) { int r; + ASSERT(one && two); + /* We don't compare user or password */ /* The scheme */ @@ -520,6 +543,8 @@ int ha_genrandom(unsigned char* data, size_t len) { int r, dd; + ASSERT(data && len > 0); + dd = open("/dev/urandom", O_RDONLY); if(dd == -1) { |