rm -f Makefile
rm -f test/Makefile
rm -f config.log
- rm -f $(SRCDIR)/md5.h $(SRCDIR)/md5.c $(SRCDIR)/strlcpy.h $(SRCDIR)/strlcpy.c $(SRCDIR)/queue.h $(SRCDIR)/config.h $(SRCDIR)/modules.c $(SRCDIR)/modules.h
+ rm -f $(SRCDIR)/md5.h $(SRCDIR)/md5.c $(SRCDIR)/queue.h $(SRCDIR)/config.h $(SRCDIR)/modules.c $(SRCDIR)/modules.h
cd perl && rm -f Makefile.old && rm -f Makefile.PL && cd ..
creategroup:
+++ /dev/null
-/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */
-
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-#include <sys/cdefs.h>
-
-#include <sys/types.h>
-#include <string.h>
-
-/*
- * Copy src to string dst of size siz. At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
- */
-size_t
-strlcpy(dst, src, siz)
- char *dst;
- const char *src;
- size_t siz;
-{
- char *d = dst;
- const char *s = src;
- size_t n = siz;
-
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
-}
+++ /dev/null
-#ifndef STRLCPY_H
-#define STRLCPY_H
-
-#include <sys/types.h>
-
-size_t strlcpy(char *, const char*, size_t);
-
-#endif
echo "#include <stdlib.h>" > autotest.c
echo "#include <EXTERN.h>" >> autotest.c
echo "#include <perl.h>" >> autotest.c
- echo "int main (int argc, char **argv) { PERL_SYS_INIT3(&argc,&argv,&env); return 0; }" >> autotest.c
+ echo "int main (int argc, char **argv, char **env) { PERL_SYS_INIT3(&argc,&argv,&env); return 0; }" >> autotest.c
echo "$GCC $CFLAGS $PERLCFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PERLLDFLAGS $PTHREAD_LDFLAGS autotest.c" >>config.log
$GCC $CFLAGS $PERLCFLAGS $PTHREAD_CFLAGS -o autotest $LDFLAGS $LIBS $PERLLDFLAGS $PTHREAD_LDFLAGS autotest.c >>config.log 2>&1
if [ $? -eq 0 ] ; then
have_opt "PIDFILE"
fi
-check_function "strlcpy" "string.h"
-if [ $? -eq 1 ] ; then
- cp $COMPAT_DIR/strlcpy.c $SRCDIR
- cp $COMPAT_DIR/strlcpy.h $SRCDIR
- SOURCES="$SOURCES strlcpy.c"
- DEPS="$DEPS $SRCDIR/strlcpy.h"
- have_opt "STRLCPY_H"
-fi
check_function "bzero" "string.h"
check_function "srandomdev"
if [ $? -eq 0 ] ; then
if [ $? -eq 1 ] ; then
check_include "inttypes.h"
fi
-check_include "strlcpy.h"
check_include "md5.h"
check_include "sys/queue.h"
if [ $? -eq 1 ] ; then
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
+#include <glib.h>
#include "../src/config.h"
#include "../src/main.h"
RETVAL = newHV();
type = g_mime_content_type_to_string (part->type);
- hv_store_ent (RETVAL,
+ (void)hv_store_ent (RETVAL,
newSVpv ("type", sizeof ("type") - 1),
newSVpv (type, strlen(type)), 0);
- hv_store_ent (RETVAL,
+ (void)hv_store_ent (RETVAL,
newSVpv ("content", sizeof ("content") - 1),
newSVpv ((char *)part->content->data, part->content->len), 0);
sv_2mortal((SV*)RETVAL);
callback_data->task = r;
ctx->callback_data = (void *)callback_data;
- strlcpy (param.key, key, sizeof (param.key));
+ g_strlcpy (param.key, key, sizeof (param.key));
param.buf = memory_pool_alloc (r->task_pool, datalen);
if (param.buf != NULL) {
param.bufsize = datalen;
callback_data->task = r;
ctx->callback_data = (void *)callback_data;
- strlcpy (param.key, key, sizeof (param.key));
+ g_strlcpy (param.key, key, sizeof (param.key));
param.buf = data;
param.bufsize = datalen;
param.bufpos = 0;
callback_data->task = r;
ctx->callback_data = (void *)callback_data;
- strlcpy (param.key, key, sizeof (param.key));
+ g_strlcpy (param.key, key, sizeof (param.key));
param.buf = NULL;
param.bufsize = 0;
param.bufpos = 0;
}
/* If uptime is less than 1 minute print only seconds */
else if (uptime / 60 == 0) {
- r = snprintf (out_buf, sizeof (out_buf), "%dsecond%s", uptime, uptime > 1 ? "s" : " ");
+ r = snprintf (out_buf, sizeof (out_buf), "%dsecond%s", (int)uptime, (int)uptime > 1 ? "s" : " ");
}
/* Else print the minutes and seconds. */
else {
}
int
-main (int argc, char **argv)
+main (int argc, char **argv, char **env)
{
struct rspamd_main *rspamd;
struct module_ctx *cur_module = NULL;
iov[2].iov_len = ctx->param->bufsize - ctx->param->bufpos;
iov[3].iov_base = CRLF;
iov[3].iov_len = sizeof (CRLF) - 1;
- writev (ctx->sock, iov, 4);
+ if (writev (ctx->sock, iov, 4) == -1) {
+ memc_log (ctx, __LINE__, "memc_write: writev failed: %m");
+ }
}
else {
iov[0].iov_base = read_buf;
iov[0].iov_len = sizeof (struct memc_udp_header);
iov[1].iov_base = read_buf;
iov[1].iov_len = r;
- writev (ctx->sock, iov, 2);
+ if (writev (ctx->sock, iov, 2) == -1) {
+ memc_log (ctx, __LINE__, "memc_write: writev failed: %m");
+ }
}
else {
- write (ctx->sock, read_buf, r);
+ if (write (ctx->sock, read_buf, r) == -1) {
+ memc_log (ctx, __LINE__, "memc_write: write failed: %m");
+ }
}
event_del (&ctx->mem_ev);
event_set (&ctx->mem_ev, ctx->sock, EV_READ | EV_PERSIST | EV_TIMEOUT, socket_callback, (void *)ctx);
iov[1].iov_base = read_buf;
iov[1].iov_len = r;
ctx->param->bufpos = writev (ctx->sock, iov, 2);
+ if (ctx->param->bufpos == -1) {
+ memc_log (ctx, __LINE__, "memc_write: writev failed: %m");
+ }
}
else {
- write (ctx->sock, read_buf, r);
+ if (write (ctx->sock, read_buf, r) == -1) {
+ memc_log (ctx, __LINE__, "memc_write: write failed: %m");
+ }
}
event_del (&ctx->mem_ev);
event_set (&ctx->mem_ev, ctx->sock, EV_READ | EV_PERSIST | EV_TIMEOUT, socket_callback, (void *)ctx);
switch (ctx->op) {
case CMD_CONNECT:
if (error != OK) {
- msg_info ("memcached_callback: memcached returned error %s on CONNECT stage");
+ msg_info ("memcached_callback: memcached returned error %s on CONNECT stage", memc_strerror (error));
memc_close_ctx (param->ctx);
param->task->save.saved --;
if (param->task->save.saved == 0) {
break;
case CMD_READ:
if (error != OK) {
- msg_info ("memcached_callback: memcached returned error %s on READ stage");
+ msg_info ("memcached_callback: memcached returned error %s on READ stage", memc_strerror (error));
memc_close_ctx (param->ctx);
param->task->save.saved --;
if (param->task->save.saved == 0) {
break;
case CMD_WRITE:
if (error != OK) {
- msg_info ("memcached_callback: memcached returned error %s on WRITE stage");
+ msg_info ("memcached_callback: memcached returned error %s on WRITE stage", memc_strerror (error));
}
memc_close_ctx (param->ctx);
param->task->save.saved --;
cur_param->bufsize = sizeof (int);
sum_str = g_compute_checksum_for_string (G_CHECKSUM_MD5, struri (url), -1);
- strlcpy (cur_param->key, sum_str, sizeof (cur_param->key));
+ g_strlcpy (cur_param->key, sum_str, sizeof (cur_param->key));
g_free (sum_str);
selected = (struct memcached_server *) get_upstream_by_hash ((void *)task->cfg->memcached_servers,
event_set (¶m->ev, param->sock, EV_READ | EV_PERSIST | EV_TIMEOUT, redirector_callback, (void *)param);
event_add (¶m->ev, &timeout);
r = snprintf (url_buf, sizeof (url_buf), "GET %s HTTP/1.0\r\n\r\n", struri (param->url));
- write (param->sock, url_buf, r);
+ if (write (param->sock, url_buf, r) == -1) {
+ msg_err ("redirector_callback: write failed %m");
+ event_del (¶m->ev);
+ param->task->save.saved --;
+ if (param->task->save.saved == 0) {
+ /* Call other filters */
+ param->task->save.saved = 1;
+ process_filters (param->task);
+ }
+ g_free (param);
+ return;
+ }
param->state = STATE_READ;
}
else {
char outbuf[OUTBUFSIZ];
struct metric_result *metric_res;
- r = snprintf (outbuf, sizeof (outbuf), "%s 0 %s" CRLF, (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER);
+ r = snprintf (outbuf, sizeof (outbuf), "%s 0 %s" CRLF, (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER, "OK");
bufferevent_write (task->bev, outbuf, r);
if (task->proto == SPAMC_PROTO) {
/* Ignore metrics, just write report for 'default' metric */
char outbuf[OUTBUFSIZ];
r = snprintf (outbuf, sizeof (outbuf), "%s 0 %s" CRLF "Content-Length: %zd" CRLF CRLF,
- (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER, task->msg->buf->len);
+ (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER, "OK", task->msg->buf->len);
bufferevent_write (task->bev, outbuf, r);
bufferevent_write (task->bev, task->msg->buf->begin, task->msg->buf->len);
}
if (st.st_size > pool->max) {
- msg_info ("statfile_pool_open: cannot attach file to pool, too large: %zd", st.st_size);
+ msg_info ("statfile_pool_open: cannot attach file to pool, too large: %zd", (size_t)st.st_size);
return -1;
}
if (c != p) {
/* Copy operand */
str = memory_pool_alloc (pool, p - c + 1);
- strlcpy (str, c, (p - c + 1));
+ g_strlcpy (str, c, (p - c + 1));
insert_expression (pool, &expr, EXPR_OPERAND, 0, str);
}
if (*p == ')') {
if (c != p) {
/* Copy operand */
str = memory_pool_alloc (pool, p - c + 1);
- strlcpy (str, c, (p - c + 1));
+ g_strlcpy (str, c, (p - c + 1));
insert_expression (pool, &expr, EXPR_OPERAND, 0, str);
}
/* Pop everything from stack */
openlog ("rspamd", LOG_NDELAY | LOG_PID, cfg->log_facility);
return 0;
case RSPAMD_LOG_FILE:
- cfg->log_fd = open (cfg->log_file, O_CREAT | O_WRONLY | O_APPEND);
+ cfg->log_fd = open (cfg->log_file, O_CREAT | O_WRONLY | O_APPEND, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
if (cfg->log_fd == -1) {
msg_err ("open_log: cannot open desired log file: %s, %m", cfg->log_file);
return -1;
if (log_level <= cfg->log_level) {
if (log_level >= G_LOG_LEVEL_DEBUG) {
- syslog (LOG_DEBUG, message);
+ syslog (LOG_DEBUG, "%s", message);
}
else if (log_level >= G_LOG_LEVEL_INFO) {
- syslog (LOG_INFO, message);
+ syslog (LOG_INFO, "%s", message);
}
else if (log_level >= G_LOG_LEVEL_WARNING) {
- syslog (LOG_WARNING, message);
+ syslog (LOG_WARNING, "%s", message);
}
else if (log_level >= G_LOG_LEVEL_CRITICAL) {
- syslog (LOG_ERR, message);
+ syslog (LOG_ERR, "%s", message);
}
}
}
-#if HAVE_STRLCPY_H
-../src/strlcpy.c
-#endif
../src/mem_pool.c
../src/url.c
../src/util.c
ctx->timeout.tv_usec = 0;
ctx->sock = -1;
ctx->options = MEMC_OPT_DEBUG;
- strlcpy (param->key, buf, sizeof (param->key));
+ g_strlcpy (param->key, buf, sizeof (param->key));
param->buf = buf;
param->bufsize = strlen (buf);
ctx->param = param;
-#if HAVE_STRLCPY_H
-../src/strlcpy.c
-#endif
../src/mem_pool.c
../src/url.c
../src/util.c