From 98eb3dd982420b64cc35010c4134caeeeb726081 Mon Sep 17 00:00:00 2001 From: laforge Date: Wed, 16 Feb 2005 10:05:31 +0000 Subject: fix log-ip-as-string on x86_64 (Javi Averbach) --- ulogd/mysql/ulogd_MYSQL.c | 6 +++++- ulogd/pgsql/ulogd_PGSQL.c | 6 +++++- ulogd/sqlite3/ulogd_SQLITE3.c | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'ulogd') 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 #include +#include #include #include #include @@ -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 #include +#include #include #include #include @@ -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 #include +#include #include #include #include @@ -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 */ -- cgit v1.2.3