diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-06-24 20:57:05 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-06-24 20:57:05 +0400 |
commit | 62108fe767966d44e43f4b23094f220dd0d6bf27 (patch) | |
tree | b87a61491189f85f57f387ee99e7844f750a92c1 /src/plugins | |
parent | 4536c2547b508cfa575218f6ebc147bf471ba465 (diff) | |
download | rspamd-62108fe767966d44e43f4b23094f220dd0d6bf27.tar.gz rspamd-62108fe767966d44e43f4b23094f220dd0d6bf27.zip |
* Use rspamd_snprintf instead of libc one
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/fuzzy_check.c | 20 | ||||
-rw-r--r-- | src/plugins/surbl.c | 26 |
2 files changed, 23 insertions, 23 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 198cf08e4..da301ddca 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -383,7 +383,7 @@ fuzzy_io_callback (int fd, short what, void *arg) nval = fuzzy_normalize (value, map->weight); } - snprintf (buf, sizeof (buf), "%d: %d / %.2f", flag, value, nval); + rspamd_snprintf (buf, sizeof (buf), "%d: %d / %.2f", flag, value, nval); insert_result (session->task, symbol, nval, g_list_prepend (NULL, memory_pool_strdup (session->task->task_pool, buf))); } @@ -445,14 +445,14 @@ fuzzy_learn_callback (int fd, short what, void *arg) goto err; } else if (buf[0] == 'O' && buf[1] == 'K') { - r = snprintf (buf, sizeof (buf), "OK" CRLF); + r = rspamd_snprintf (buf, sizeof (buf), "OK" CRLF); if (! rspamd_dispatcher_write (session->session->dispatcher, buf, r, FALSE, FALSE)) { return; } goto ok; } else { - r = snprintf (buf, sizeof (buf), "ERR" CRLF); + r = rspamd_snprintf (buf, sizeof (buf), "ERR" CRLF); if (! rspamd_dispatcher_write (session->session->dispatcher, buf, r, FALSE, FALSE)) { return; } @@ -468,7 +468,7 @@ fuzzy_learn_callback (int fd, short what, void *arg) err: msg_err ("got error in IO with server %s:%d, %d, %s", session->server->name, session->server->port, errno, strerror (errno)); - r = snprintf (buf, sizeof (buf), "Error" CRLF); + r = rspamd_snprintf (buf, sizeof (buf), "Error" CRLF); if (! rspamd_dispatcher_write (session->session->dispatcher, buf, r, FALSE, FALSE)) { return; } @@ -581,7 +581,7 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in) msg_warn ("processing of message failed"); free_task (task, FALSE); session->state = STATE_REPLY; - r = snprintf (out_buf, sizeof (out_buf), "cannot process message" CRLF); + r = rspamd_snprintf (out_buf, sizeof (out_buf), "cannot process message" CRLF); if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE)) { msg_warn ("write error"); } @@ -612,7 +612,7 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in) if ((sock = make_udp_socket (&selected->addr, selected->port, FALSE, TRUE)) == -1) { msg_warn ("cannot connect to %s, %d, %s", selected->name, errno, strerror (errno)); session->state = STATE_REPLY; - r = snprintf (out_buf, sizeof (out_buf), "no hashes written" CRLF); + r = rspamd_snprintf (out_buf, sizeof (out_buf), "no hashes written" CRLF); if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE)) { return; } @@ -643,7 +643,7 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in) else { /* Cannot write hash */ session->state = STATE_REPLY; - r = snprintf (out_buf, sizeof (out_buf), "cannot write fuzzy hash" CRLF); + r = rspamd_snprintf (out_buf, sizeof (out_buf), "cannot write fuzzy hash" CRLF); if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE)) { return; } @@ -657,7 +657,7 @@ fuzzy_process_handler (struct controller_session *session, f_str_t * in) free_task (task, FALSE); if (*saved == 0) { session->state = STATE_REPLY; - r = snprintf (out_buf, sizeof (out_buf), "no hashes written" CRLF); + r = rspamd_snprintf (out_buf, sizeof (out_buf), "no hashes written" CRLF); if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE)) { return; } @@ -675,7 +675,7 @@ fuzzy_controller_handler (char **args, struct controller_session *session, int c arg = args[0]; if (!arg || *arg == '\0') { msg_info ("empty content length"); - r = snprintf (out_buf, sizeof (out_buf), "fuzzy command requires length as argument" CRLF); + r = rspamd_snprintf (out_buf, sizeof (out_buf), "fuzzy command requires length as argument" CRLF); if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE)) { return; } @@ -685,7 +685,7 @@ fuzzy_controller_handler (char **args, struct controller_session *session, int c errno = 0; size = strtoul (arg, &err_str, 10); if (errno != 0 || (err_str && *err_str != '\0')) { - r = snprintf (out_buf, sizeof (out_buf), "learn size is invalid" CRLF); + r = rspamd_snprintf (out_buf, sizeof (out_buf), "learn size is invalid" CRLF); if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE)) { return; } diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 699bd79d1..90f2bc5fe 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -322,7 +322,7 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it if (is_numeric && dots_num == 3) { /* This is ip address */ result = memory_pool_alloc (pool, len); - r = snprintf (result, len, "%*s.%*s.%*s.%*s", + r = rspamd_snprintf (result, len, "%*s.%*s.%*s.%*s", (int)(hostname->len - (dots[2] - hostname->begin + 1)), dots[2] + 1, (int)(dots[2] - dots[1] - 1), @@ -350,7 +350,7 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it /* Hack for bugged windows resolver */ ip_num &= 0xFFFFFFFF; /* Get octets */ - r = snprintf (result, len, "%u.%u.%u.%u", + r = rspamd_snprintf (result, len, "%u.%u.%u.%u", (uint32_t) ip_num & 0x000000FF, (uint32_t) (ip_num & 0x0000FF00) >> 8, (uint32_t) (ip_num & 0x00FF0000) >> 16, (uint32_t) (ip_num & 0xFF000000) >> 24); } else { @@ -370,21 +370,21 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it } if (level != MAX_LEVELS) { if (level == 0) { - r = snprintf (result, len, "%*s", (int)hostname->len, hostname->begin); + r = rspamd_snprintf (result, len, "%*s", (int)hostname->len, hostname->begin); } else { - r = snprintf (result, len, "%*s", + r = rspamd_snprintf (result, len, "%*s", (int)(hostname->len - (dots[level - 1] - hostname->begin + 1)), dots[level - 1] + 1); } } else if (dots_num >= 2) { - r = snprintf (result, len, "%*s", + r = rspamd_snprintf (result, len, "%*s", (int)(hostname->len - (dots[dots_num - 2] - hostname->begin + 1)), dots[dots_num - 2] + 1); } else { - r = snprintf (result, len, "%*s", (int)hostname->len, hostname->begin); + r = rspamd_snprintf (result, len, "%*s", (int)hostname->len, hostname->begin); } } @@ -399,7 +399,7 @@ format_surbl_request (memory_pool_t * pool, f_str_t * hostname, struct suffix_it if (append_suffix) { - r += snprintf (result + r, len - r, ".%s", suffix->suffix); + r += rspamd_snprintf (result + r, len - r, ".%s", suffix->suffix); } msg_debug ("request: %s, dots: %d, level: %d, orig: %*s", result, dots_num, level, (int)hostname->len, hostname->begin); @@ -469,7 +469,7 @@ process_dns_results (struct worker_task *task, struct suffix_item *suffix, char len = strlen (suffix->symbol) - 2 + strlen (bit->symbol) + 1; *c = '\0'; symbol = memory_pool_alloc (task->task_pool, len); - snprintf (symbol, len, "%s%s%s", suffix->symbol, bit->symbol, c + 2); + rspamd_snprintf (symbol, len, "%s%s%s", suffix->symbol, bit->symbol, c + 2); *c = '%'; insert_result (task, symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, url))); found = 1; @@ -665,7 +665,7 @@ redirector_callback (int fd, short what, void *arg) event_del (¶m->ev); event_set (¶m->ev, param->sock, EV_READ | EV_PERSIST, 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)); + r = rspamd_snprintf (url_buf, sizeof (url_buf), "GET %s HTTP/1.0\r\n\r\n", struri (param->url)); if (write (param->sock, url_buf, r) == -1) { msg_err ("write failed %s", strerror (errno)); remove_normal_event (param->task->s, free_redirector_session, param); @@ -839,9 +839,9 @@ urls_command_handler (struct worker_task *task) outbuf = memory_pool_alloc (task->task_pool, buflen * sizeof (char)); - r = snprintf (outbuf, buflen, "%s 0 %s" CRLF, (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER, "OK"); + r = rspamd_snprintf (outbuf, buflen, "%s 0 %s" CRLF, (task->proto == SPAMC_PROTO) ? SPAMD_REPLY_BANNER : RSPAMD_REPLY_BANNER, "OK"); - r += snprintf (outbuf + r, buflen - r - 2, "URLs: "); + r += rspamd_snprintf (outbuf + r, buflen - r - 2, "URLs: "); cur = g_list_first (task->urls); @@ -854,10 +854,10 @@ urls_command_handler (struct worker_task *task) f.len = url->hostlen; if ((urlstr = format_surbl_request (task->task_pool, &f, NULL, FALSE, &err)) != NULL) { if (g_list_next (cur) != NULL) { - r += snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">, ", (char *)urlstr, struri (url)); + r += rspamd_snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">, ", (char *)urlstr, struri (url)); } else { - r += snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">", (char *)urlstr, struri (url)); + r += rspamd_snprintf (outbuf + r, buflen - r - 2, "%s <\"%s\">", (char *)urlstr, struri (url)); } } } |