summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaforge <laforge>2005-02-16 10:05:31 +0000
committerlaforge <laforge>2005-02-16 10:05:31 +0000
commit98eb3dd982420b64cc35010c4134caeeeb726081 (patch)
tree9bb84ded82c7b468617da90abf6e258cef3d97c2
parentd66a1983b792780b68c2c3b44ac8cd7de06ce66d (diff)
fix log-ip-as-string on x86_64 (Javi Averbach)
-rw-r--r--ulogd/mysql/ulogd_MYSQL.c6
-rw-r--r--ulogd/pgsql/ulogd_PGSQL.c6
-rw-r--r--ulogd/sqlite3/ulogd_SQLITE3.c6
3 files changed, 15 insertions, 3 deletions
diff --git a/ulogd/mysql/ulogd_MYSQL.c b/ulogd/mysql/ulogd_MYSQL.c
index 5b237e1..206055f 100644
--- a/ulogd/mysql/ulogd_MYSQL.c
+++ b/ulogd/mysql/ulogd_MYSQL.c
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <string.h>
+#include <arpa/inet.h>
#include <ulogd/ulogd.h>
#include <ulogd/conffile.h>
#include <mysql/mysql.h>
@@ -114,6 +115,7 @@ static int mysql_output(ulog_iret_t *result)
ulog_iret_t *res;
#ifdef IP_AS_STRING
char *tmpstr; /* need this for --log-ip-as-string */
+ struct in_addr addr;
#endif
stmt_ins = stmt_val;
@@ -154,8 +156,10 @@ static int mysql_output(ulog_iret_t *result)
break;
case ULOGD_RET_IPADDR:
#ifdef IP_AS_STRING
+ memset(&addr, 0, sizeof(addr0));
+ addr.s_addr = ntohl(res->value.ui32);
*stmt_ins++ = '\'';
- tmpstr = inet_ntoa(ntohl(res->value.ui32));
+ tmpstr = inet_ntoa(addr);
#ifdef OLD_MYSQL
mysql_escape_string(stmt_ins, tmpstr,
strlen(tmpstr));
diff --git a/ulogd/pgsql/ulogd_PGSQL.c b/ulogd/pgsql/ulogd_PGSQL.c
index 74392a3..39c88bd 100644
--- a/ulogd/pgsql/ulogd_PGSQL.c
+++ b/ulogd/pgsql/ulogd_PGSQL.c
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <string.h>
+#include <arpa/inet.h>
#include <ulogd/ulogd.h>
#include <ulogd/conffile.h>
#include <libpq-fe.h>
@@ -94,6 +95,7 @@ static int pgsql_output(ulog_iret_t *result)
PGresult *pgres;
#ifdef IP_AS_STRING
char *tmpstr; /* need this for --log-ip-as-string */
+ struct in_addr addr;
#endif
stmt_ins = stmt_val;
@@ -135,7 +137,9 @@ static int pgsql_output(ulog_iret_t *result)
case ULOGD_RET_IPADDR:
#ifdef IP_AS_STRING
*stmt_ins++ = '\'';
- tmpstr = (char *)inet_ntoa(ntohl(res->value.ui32));
+ memset(&addr, 0, sizeof(addr));
+ addr.s_addr = ntohl(res->value.ui32);
+ tmpstr = (char *)inet_ntoa(addr);
PQescapeString(stmt_ins,tmpstr,strlen(tmpstr));
stmt_ins = stmt + strlen(stmt);
sprintf(stmt_ins, "',");
diff --git a/ulogd/sqlite3/ulogd_SQLITE3.c b/ulogd/sqlite3/ulogd_SQLITE3.c
index cc45f9a..284da3c 100644
--- a/ulogd/sqlite3/ulogd_SQLITE3.c
+++ b/ulogd/sqlite3/ulogd_SQLITE3.c
@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <string.h>
+#include <arpa/inet.h>
#include <ulogd/ulogd.h>
#include <ulogd/conffile.h>
#include <sqlite3.h>
@@ -92,6 +93,7 @@ static int _sqlite3_output(ulog_iret_t *result)
int col_counter;
#ifdef IP_AS_STRING
char *ipaddr;
+ struct in_addr *addr;
#endif
col_counter = 0;
@@ -130,7 +132,9 @@ static int _sqlite3_output(ulog_iret_t *result)
break;
case ULOGD_RET_IPADDR:
#ifdef IP_AS_STRING
- ipaddr = inet_ntoa(ntohl(res->value.ui32));
+ memset(&addr, 0, sizeof(addr));
+ addr.s_addr = ntohl(res->value.ui32);
+ ipaddr = inet_ntoa(addr);
sqlite3_bind_text(p_stmt,col_counter,ipaddr,strlen(ipaddr),SQLITE_STATIC);
break;
#endif /* IP_AS_STRING */