summaryrefslogtreecommitdiff
path: root/libdaemon
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2015-03-05 14:00:44 -0600
committerDavid Teigland <teigland@redhat.com>2015-07-02 15:42:26 -0500
commitfe70b03de2956b6493993990d9fb1cde3f41ebcd (patch)
tree20313364aa6f69c38993ac9b7a95a3c496484d06 /libdaemon
parenta32d5a4afc5bdc4585132765fb02739a8f352e49 (diff)
downloadlvm2-fe70b03de2956b6493993990d9fb1cde3f41ebcd.tar.gz
Diffstat (limited to 'libdaemon')
-rw-r--r--libdaemon/client/daemon-client.c16
-rw-r--r--libdaemon/server/daemon-log.c5
2 files changed, 16 insertions, 5 deletions
diff --git a/libdaemon/client/daemon-client.c b/libdaemon/client/daemon-client.c
index d37b96658..991bf8a0a 100644
--- a/libdaemon/client/daemon-client.c
+++ b/libdaemon/client/daemon-client.c
@@ -21,7 +21,6 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
-#include <assert.h>
#include <errno.h> // ENOMEM
daemon_handle daemon_open(daemon_info i)
@@ -100,7 +99,13 @@ daemon_reply daemon_send(daemon_handle h, daemon_request rq)
{
struct buffer buffer;
daemon_reply reply = { 0 };
- assert(h.socket_fd >= 0);
+
+ if (h.socket_fd < 0) {
+ log_error(INTERNAL_ERROR "Daemon send: socket fd cannot be negative %d", h.socket_fd);
+ reply.error = EINVAL;
+ return reply;
+ }
+
buffer = rq.buffer;
if (!buffer.mem)
@@ -109,7 +114,12 @@ daemon_reply daemon_send(daemon_handle h, daemon_request rq)
return reply;
}
- assert(buffer.mem);
+ if (!buffer.mem) {
+ log_error(INTERNAL_ERROR "Daemon send: no memory available");
+ reply.error = ENOMEM;
+ return reply;
+ }
+
if (!buffer_write(h.socket_fd, &buffer))
reply.error = errno;
diff --git a/libdaemon/server/daemon-log.c b/libdaemon/server/daemon-log.c
index 87ad54763..c1765de3f 100644
--- a/libdaemon/server/daemon-log.c
+++ b/libdaemon/server/daemon-log.c
@@ -1,7 +1,6 @@
#include "daemon-server.h"
#include "daemon-log.h"
#include <syslog.h>
-#include <assert.h>
struct backend {
int id;
@@ -129,7 +128,9 @@ void daemon_log_multi(log_state *s, int type, const char *prefix, const char *ms
void daemon_log_enable(log_state *s, int outlet, int type, int enable)
{
- assert(type < 32);
+ if (type >= 32)
+ return;
+
if (enable)
s->log_config[type] |= outlet;
else