diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-10-20 23:32:37 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-10-20 23:32:37 +0200 |
commit | 6f19c791d4fe0d9a6c59ebecb26156f17e80eb75 (patch) | |
tree | b4ba82a46f1031687177a174befd82ee248d2d5b /main.c | |
parent | 268149290fcd8a52f377b21226990d3bf0e9c226 (diff) |
fix segfaults in log line processing
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -46,6 +46,10 @@ netifd_delete_process(struct netifd_process *proc) uloop_process_delete(&proc->uloop); list_del(&proc->list); netifd_fd_delete(&proc->log_fd); + if (proc->log_buf) { + free(proc->log_buf); + proc->log_buf = NULL; + } } void @@ -77,14 +81,13 @@ netifd_process_log_cb(struct uloop_fd *fd, unsigned int events) if (!proc->log_buf) proc->log_buf = malloc(LOG_BUF_SIZE + 1); - buf = proc->log_buf + proc->log_buf_ofs; - maxlen = LOG_BUF_SIZE - proc->log_buf_ofs; - log_prefix = proc->log_prefix; if (!log_prefix) log_prefix = "process"; retry: + buf = proc->log_buf + proc->log_buf_ofs; + maxlen = LOG_BUF_SIZE - proc->log_buf_ofs; read_len = len = read(fd->fd, buf, maxlen); if (len < 0) { if (errno == EAGAIN) @@ -196,6 +199,7 @@ netifd_start_process(const char **argv, char **env, struct netifd_process *proc) uloop_process_add(&proc->uloop); list_add_tail(&proc->list, &process_list); + proc->log_buf_ofs = 0; proc->log_uloop.fd = proc->log_fd.fd = pfds[0]; proc->log_uloop.cb = netifd_process_log_cb; netifd_fd_add(&proc->log_fd); |