summaryrefslogtreecommitdiffstats
path: root/ulogd/pgsql/ulogd_PGSQL.c
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 /ulogd/pgsql/ulogd_PGSQL.c
parentd66a1983b792780b68c2c3b44ac8cd7de06ce66d (diff)
fix log-ip-as-string on x86_64 (Javi Averbach)
Diffstat (limited to 'ulogd/pgsql/ulogd_PGSQL.c')
-rw-r--r--ulogd/pgsql/ulogd_PGSQL.c6
1 files changed, 5 insertions, 1 deletions
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, "',");