Revision: 6228 http://ipcop.svn.sourceforge.net/ipcop/?rev=6228&view=rev Author: gespinasse Date: 2012-01-11 22:04:27 +0000 (Wed, 11 Jan 2012) Log Message: ----------- Patch ulogd to fix a few string warnings (debian borrowed) Fix this libc does not define HOST_NAME_MAX (upstream borrowed) Use gcc to link instead of ld, this let our gcc -Wl,-z,now default option to be used (inspired by gentoo)
Add -Wall in CFLAGS for the pleasure to check if most compilation issue should be really fixed Modified Paths: -------------- ipcop/trunk/lfs/ulogd ipcop/trunk/updates/2.0.3/ROOTFILES.i486-2.0.3 ipcop/trunk/updates/2.0.3/information.xml Added Paths: ----------- ipcop/trunk/src/patches/ulogd-1.24_strfix.patch Modified: ipcop/trunk/lfs/ulogd =================================================================== --- ipcop/trunk/lfs/ulogd 2012-01-10 07:46:26 UTC (rev 6227) +++ ipcop/trunk/lfs/ulogd 2012-01-11 22:04:27 UTC (rev 6228) @@ -43,6 +43,8 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(STAGE_ORDER)_$(STAGE)/$(THISAPP) +CFLAGS += -Wall + ############################################################################### # Top-level Rules ############################################################################### @@ -82,6 +84,15 @@ $(TARGET) : $(firstword $(MAKEFILE_LIST)) $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) + # Fix 'call to __builtin___strncat_chk might overflow destination buffer' + # Fix 'format not a string literal and no format arguments' when -Wformat-nonliteral is used + cd $(DIR_APP) && patch -p0 -i $(DIR_PATCHES)/$(THISAPP)_strfix.patch # (debian borrowed) + # Fix 'this libc does not define HOST_NAME_MAX' + cd $(DIR_APP) && sed -i -e 's:include <stdio.h>:include <limits.h>\n#include <stdio.h>:' extensions/ulogd_LOGEMU.c + cd $(DIR_APP) && sed -i -e 's:include <stdio.h>:include <limits.h>\n#include <stdio.h>:' extensions/printpkt.c + # Call gcc instead of ld for linking as only gcc have our hardened by default options (gentoo borrowed) + # (prevents build from choking on stuff like "LDFLAGS=-Wl,O1") + cd $(DIR_APP) && for d in pgsql sqlite3 extensions mysql pcap ; do sed -i -e 's/$$(LD)/$$(CC) -nostartfiles/' $$d/Makefile.in; done # remove database(s) in case of a partial build rm -f /var/ipcop/traffic/empty-ulogd.db Added: ipcop/trunk/src/patches/ulogd-1.24_strfix.patch =================================================================== --- ipcop/trunk/src/patches/ulogd-1.24_strfix.patch (rev 0) +++ ipcop/trunk/src/patches/ulogd-1.24_strfix.patch 2012-01-11 22:04:27 UTC (rev 6228) @@ -0,0 +1,860 @@ +http://patch-tracker.debian.org/patch/series/view/ulogd/1.24-3/strfix.patch + +--- extensions/printpkt.c ++++ extensions/printpkt.c 2007/01/10 13:13:23 +@@ -95,13 +95,17 @@ + #define GET_VALUE(x) ulogd_keyh[intr_ids[x].id].interp->result[ulogd_keyh[intr_ids[x].id].offset].value + #define GET_FLAGS(x) ulogd_keyh[intr_ids[x].id].interp->result[ulogd_keyh[intr_ids[x].id].offset].flags + +-int printpkt_print(ulog_iret_t *res, char *buf, int prefix) ++int printpkt_print(ulog_iret_t *res, char *buf, size_t buf_siz, int prefix) + { + char *timestr; + char *tmp; + time_t now; + +- char *buf_cur = buf; ++ if( buf_siz) *buf = '\0'; ++ size_t buf_len = 0; ++ ++#define BUF_ADD(ptr, siz, off, fmt...) \ ++ snprintf(((ptr)+(off)), ((siz) > (off) ? (siz)-(off) : 0), ##fmt) + + if (prefix) { + now = (time_t) GET_VALUE(0).ui32; +@@ -116,127 +120,191 @@ + *tmp = '\0'; + + /* print time and hostname */ +- buf_cur += sprintf(buf_cur, "%.15s %s", timestr, hostname); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "%.15s %s", timestr, hostname); + } + + if (*(char *) GET_VALUE(1).ptr) +- buf_cur += sprintf(buf_cur, " %s", (char *) GET_VALUE(1).ptr); ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, " %s", (char *) GET_VALUE(1).ptr); ++ } + +- buf_cur += sprintf(buf_cur," IN=%s OUT=%s ", +- (char *) GET_VALUE(2).ptr, +- (char *) GET_VALUE(3).ptr); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len," IN=%s OUT=%s ", ++ (char *) GET_VALUE(2).ptr, ++ (char *) GET_VALUE(3).ptr); + + /* FIXME: configurable */ +- buf_cur += sprintf(buf_cur, "MAC=%s ", +- (GET_FLAGS(4) & ULOGD_RETF_VALID) ? (char *) GET_VALUE(4).ptr : ""); +- +- buf_cur += sprintf(buf_cur, "SRC=%s ", +- inet_ntoa((struct in_addr) {htonl(GET_VALUE(5).ui32)})); +- buf_cur += sprintf(buf_cur, "DST=%s ", +- inet_ntoa((struct in_addr) {htonl(GET_VALUE(6).ui32)})); +- +- buf_cur += sprintf(buf_cur,"LEN=%u TOS=%02X PREC=0x%02X TTL=%u ID=%u ", +- GET_VALUE(7).ui16, GET_VALUE(8).ui8 & IPTOS_TOS_MASK, +- GET_VALUE(8).ui8 & IPTOS_PREC_MASK, GET_VALUE(9).ui8, +- GET_VALUE(10).ui16); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "MAC=%s ", ++ (GET_FLAGS(4) & ULOGD_RETF_VALID) ? (char *) GET_VALUE(4).ptr : ""); ++ ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "SRC=%s ", ++ inet_ntoa((struct in_addr) {htonl(GET_VALUE(5).ui32)})); ++ ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "DST=%s ", ++ inet_ntoa((struct in_addr) {htonl(GET_VALUE(6).ui32)})); ++ ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, ++ "LEN=%u TOS=%02X PREC=0x%02X TTL=%u ID=%u ", ++ GET_VALUE(7).ui16, GET_VALUE(8).ui8 & IPTOS_TOS_MASK, ++ GET_VALUE(8).ui8 & IPTOS_PREC_MASK, GET_VALUE(9).ui8, ++ GET_VALUE(10).ui16); + + if (GET_VALUE(10).ui16 & IP_RF) +- buf_cur += sprintf(buf_cur, "CE "); ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "CE "); ++ } + + if (GET_VALUE(11).ui16 & IP_DF) +- buf_cur += sprintf(buf_cur, "DF "); ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "DF "); ++ } + + if (GET_VALUE(11).ui16 & IP_MF) +- buf_cur += sprintf(buf_cur, "MF "); ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "MF "); ++ } + + if (GET_VALUE(11).ui16 & IP_OFFMASK) +- buf_cur += sprintf(buf_cur, "FRAG:%u ", ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "FRAG:%u ", + GET_VALUE(11).ui16 & IP_OFFMASK); ++ } + + switch (GET_VALUE(12).ui8) { + + case IPPROTO_TCP: +- buf_cur += sprintf(buf_cur, "PROTO=TCP "); +- buf_cur += sprintf(buf_cur, "SPT=%u DPT=%u ", +- GET_VALUE(13).ui16, GET_VALUE(14).ui16); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "PROTO=TCP "); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "SPT=%u DPT=%u ", ++ GET_VALUE(13).ui16, GET_VALUE(14).ui16); + /* FIXME: config */ +- buf_cur += sprintf(buf_cur, "SEQ=%u ACK=%u ", +- GET_VALUE(15).ui32, GET_VALUE(16).ui32); +- +- buf_cur += sprintf(buf_cur, "WINDOW=%u ", GET_VALUE(17).ui16); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "SEQ=%u ACK=%u ", ++ GET_VALUE(15).ui32, GET_VALUE(16).ui32); ++ ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, ++ "WINDOW=%u ", GET_VALUE(17).ui16); + +-// buf_cur += sprintf(buf_cur, "RES=0x%02x ", ++// buf_len = strlen(buf); ++// BUF_ADD(buf,buf_siz,buf_len, "RES=0x%02x ", + + if (GET_VALUE(18).b) +- buf_cur += sprintf(buf_cur, "URG "); ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "URG "); ++ } + + if (GET_VALUE(19).b) +- buf_cur += sprintf(buf_cur, "ACK "); ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "ACK "); ++ } + + if (GET_VALUE(20).b) +- buf_cur += sprintf(buf_cur, "PSH "); ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "PSH "); ++ } + + if (GET_VALUE(21).b) +- buf_cur += sprintf(buf_cur, "RST "); ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "RST "); ++ } + + if (GET_VALUE(22).b) +- buf_cur += sprintf(buf_cur, "SYN "); ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "SYN "); ++ } + + if (GET_VALUE(23).b) +- buf_cur += sprintf(buf_cur, "FIN "); ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "FIN "); ++ } + +- buf_cur += sprintf(buf_cur, "URGP=%u ", GET_VALUE(24).ui16); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "URGP=%u ", GET_VALUE(24).ui16); + + break; + case IPPROTO_UDP: + +- buf_cur += sprintf(buf_cur, "PROTO=UDP "); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "PROTO=UDP "); + +- buf_cur += sprintf(buf_cur, "SPT=%u DPT=%u LEN=%u ", ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "SPT=%u DPT=%u LEN=%u ", + GET_VALUE(25).ui16, GET_VALUE(26).ui16, + GET_VALUE(27).ui16); + break; + case IPPROTO_ICMP: + +- buf_cur += sprintf(buf_cur, "PROTO=ICMP "); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "PROTO=ICMP "); + +- buf_cur += sprintf(buf_cur, "TYPE=%u CODE=%u ", ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "TYPE=%u CODE=%u ", + GET_VALUE(28).ui8, GET_VALUE(29).ui8); + + switch (GET_VALUE(28).ui8) { + case ICMP_ECHO: + case ICMP_ECHOREPLY: +- buf_cur += sprintf(buf_cur, "ID=%u SEQ=%u ", ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "ID=%u SEQ=%u ", + GET_VALUE(30).ui16, + GET_VALUE(31).ui16); + break; + case ICMP_PARAMETERPROB: +- buf_cur += sprintf(buf_cur, "PARAMETER=%u ", ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "PARAMETER=%u ", + GET_VALUE(32).ui32 >> 24); + break; + case ICMP_REDIRECT: +- buf_cur += sprintf(buf_cur, "GATEWAY=%s ", inet_ntoa((struct in_addr) {htonl(GET_VALUE(32).ui32)})); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "GATEWAY=%s ", inet_ntoa((struct in_addr) {htonl(GET_VALUE(32).ui32)})); + break; + case ICMP_DEST_UNREACH: + if (GET_VALUE(29).ui8 == ICMP_FRAG_NEEDED) +- buf_cur += sprintf(buf_cur, "MTU=%u ", ++ { ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "MTU=%u ", + GET_VALUE(33).ui16); ++ } + break; + } + break; + case IPPROTO_ESP: + case IPPROTO_AH: +- buf_cur += sprintf(buf_cur, "PROTO=%s ", GET_VALUE(12).ui8 == IPPROTO_ESP ? "ESP" : "AH"); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "PROTO=%s ", GET_VALUE(12).ui8 == IPPROTO_ESP ? "ESP" : "AH"); + /* FIXME: "INCOMPLETE [%u bytes]" in case of short pkt */ + if (intr_ids[34].id > 0) { +- buf_cur += sprintf(buf_cur, "SPI=0x%x ", GET_VALUE(34).ui32); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "SPI=0x%x ", GET_VALUE(34).ui32); + } + break; + default: + +- buf_cur += sprintf(buf_cur, "PROTO=%u ", GET_VALUE(12).ui8); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "PROTO=%u ", GET_VALUE(12).ui8); + } +- strcat(buf_cur, "\n"); ++ buf_len = strlen(buf); ++ BUF_ADD(buf,buf_siz,buf_len, "\n"); ++ ++#undef BUF_ADD + + return 0; + } +--- extensions/printpkt.h ++++ extensions/printpkt.h 2007/01/10 13:13:23 +@@ -1,7 +1,7 @@ + #ifndef _PRINTPKT_H + #define _PRINTPKT_H + +-int printpkt_print(ulog_iret_t *res, char *buf, int prefix); ++int printpkt_print(ulog_iret_t *res, char *buf, size_t buf_siz, int prefix); + int printpkt_init(void); + + #endif +--- extensions/ulogd_LOGEMU.c ++++ extensions/ulogd_LOGEMU.c 2007/01/10 13:13:23 +@@ -67,7 +67,7 @@ + { + static char buf[4096]; + +- printpkt_print(res, buf, 1); ++ printpkt_print(res, buf, sizeof(buf), 1); + + fprintf(of, "%s", buf); + +--- extensions/ulogd_SYSLOG.c ++++ extensions/ulogd_SYSLOG.c 2007/01/10 13:13:23 +@@ -61,7 +61,7 @@ + { + static char buf[4096]; + +- printpkt_print(res, buf, 0); +- syslog(syslog_level|syslog_facility, buf); ++ printpkt_print(res, buf, sizeof(buf), 0); ++ syslog(syslog_level|syslog_facility, "%s", buf); + + return 0; +--- mysql/ulogd_MYSQL.c ++++ mysql/ulogd_MYSQL.c 2007/01/10 13:13:23 +@@ -39,6 +39,7 @@ + #include <ulogd/ulogd.h> + #include <ulogd/conffile.h> + #include <mysql/mysql.h> ++#include <inttypes.h> + + #ifdef DEBUG_MYSQL + #define DEBUGP(x, args...) fprintf(stderr, x, ## args) +@@ -61,6 +62,9 @@ + /* buffer for our insert statement */ + static char *stmt; + ++/* size of our insert statement buffer */ ++static size_t stmt_siz; ++ + /* pointer to the beginning of the "VALUES" part */ + static char *stmt_val; + +@@ -130,71 +134,85 @@ + + if (!res || !IS_VALID((*res))) { + /* no result, we have to fake something */ +- sprintf(stmt_ins, "NULL,"); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "NULL,"); + stmt_ins = stmt + strlen(stmt); + continue; + } + + switch (res->type) { + case ULOGD_RET_INT8: +- sprintf(stmt_ins, "%d,", res->value.i8); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%d,", res->value.i8); + break; + case ULOGD_RET_INT16: +- sprintf(stmt_ins, "%d,", res->value.i16); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%d,", res->value.i16); + break; + case ULOGD_RET_INT32: +- sprintf(stmt_ins, "%d,", res->value.i32); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%d,", res->value.i32); + break; + case ULOGD_RET_INT64: +- sprintf(stmt_ins, "%lld,", res->value.i64); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%"PRId64",", res->value.i64); + break; + case ULOGD_RET_UINT8: +- sprintf(stmt_ins, "%u,", res->value.ui8); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%u,", res->value.ui8); + break; + case ULOGD_RET_UINT16: +- sprintf(stmt_ins, "%u,", res->value.ui16); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%u,", res->value.ui16); + break; + case ULOGD_RET_IPADDR: + #ifdef IP_AS_STRING + memset(&addr, 0, sizeof(addr)); + addr.s_addr = ntohl(res->value.ui32); +- *stmt_ins++ = '\''; + tmpstr = inet_ntoa(addr); ++ if(stmt_siz > (stmt_ins-stmt)+(strlen(tmpstr)*2)+4) ++ { ++ *stmt_ins++ = '\''; + #ifdef OLD_MYSQL +- mysql_escape_string(stmt_ins, tmpstr, +- strlen(tmpstr)); ++ mysql_escape_string(stmt_ins, tmpstr, ++ strlen(tmpstr)); + #else +- mysql_real_escape_string(dbh, stmt_ins, +- tmpstr, +- strlen(tmpstr)); ++ mysql_real_escape_string(dbh, stmt_ins, ++ tmpstr, ++ strlen(tmpstr)); + #endif /* OLD_MYSQL */ +- stmt_ins = stmt + strlen(stmt); +- sprintf(stmt_ins, "',"); ++ stmt_ins = stmt + strlen(stmt); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "',"); ++ } ++ else ++ { ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "'',"); ++ } + break; + #endif /* IP_AS_STRING */ + /* EVIL: fallthrough when logging IP as + * u_int32_t */ + case ULOGD_RET_UINT32: +- sprintf(stmt_ins, "%u,", res->value.ui32); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%u,", res->value.ui32); + break; + case ULOGD_RET_UINT64: +- sprintf(stmt_ins, "%llu,", res->value.ui64); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%"PRIu64",", res->value.ui64); + break; + case ULOGD_RET_BOOL: +- sprintf(stmt_ins, "'%d',", res->value.b); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "'%d',", res->value.b); + break; + case ULOGD_RET_STRING: +- *stmt_ins++ = '\''; ++ if(stmt_siz > (stmt_ins-stmt)+(strlen(res->value.ptr)*2)+4) ++ { ++ *stmt_ins++ = '\''; + #ifdef OLD_MYSQL +- mysql_escape_string(stmt_ins, res->value.ptr, +- strlen(res->value.ptr)); ++ mysql_escape_string(stmt_ins, res->value.ptr, ++ strlen(res->value.ptr)); + #else +- mysql_real_escape_string(dbh, stmt_ins, +- res->value.ptr, strlen(res->value.ptr)); ++ mysql_real_escape_string(dbh, stmt_ins, ++ res->value.ptr, strlen(res->value.ptr)); + #endif +- stmt_ins = stmt + strlen(stmt); +- sprintf(stmt_ins, "',"); +- /* sprintf(stmt_ins, "'%s',", res->value.ptr); */ ++ stmt_ins = stmt + strlen(stmt); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "',"); ++ } ++ else ++ { ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "'',"); ++ } ++ /* snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "'%s',", res->value.ptr); */ + break; + case ULOGD_RET_RAW: + ulogd_log(ULOGD_NOTICE, +@@ -230,7 +248,7 @@ + static int mysql_createstmt(void) + { + struct _field *f; +- unsigned int size; ++ size_t size; + char buf[ULOGD_MAX_KEYLEN]; + char *underscore; + +@@ -241,7 +259,7 @@ + } + + /* caclulate the size for the insert statement */ +- size = strlen(MYSQL_INSERTTEMPL) + strlen(table_ce.u.string); ++ size = strlen(MYSQL_INSERTTEMPL) + strlen(table_ce.u.string) + 1; + + for (f = fields; f; f = f->next) { + /* we need space for the key and a comma, as well as +@@ -252,25 +270,26 @@ + ulogd_log(ULOGD_DEBUG, "allocating %u bytes for statement\n", size); + + stmt = (char *) malloc(size); +- + if (!stmt) { + ulogd_log(ULOGD_ERROR, "OOM!\n"); + return -1; + } ++ stmt_siz = size; + +- sprintf(stmt, "insert into %s (", table_ce.u.string); ++ snprintf(stmt, stmt_siz, "insert into %s (", table_ce.u.string); + stmt_val = stmt + strlen(stmt); + + for (f = fields; f; f = f->next) { +- strncpy(buf, f->name, ULOGD_MAX_KEYLEN); ++ strncpy(buf, f->name, ULOGD_MAX_KEYLEN-1); ++ buf[ULOGD_MAX_KEYLEN-1] = '\0'; + while ((underscore = strchr(buf, '.'))) + *underscore = '_'; +- sprintf(stmt_val, "%s,", buf); ++ snprintf(stmt_val, stmt_siz-(stmt_val-stmt), "%s,", buf); + stmt_val = stmt + strlen(stmt); + } + *(stmt_val - 1) = ')'; + +- sprintf(stmt_val, " values ("); ++ snprintf(stmt_val, stmt_siz-(stmt_val-stmt), " values ("); + stmt_val = stmt + strlen(stmt); + + ulogd_log(ULOGD_DEBUG, "stmt='%s'\n", stmt); +@@ -298,7 +317,8 @@ + while ((field = mysql_fetch_field(result))) { + + /* replace all underscores with dots */ +- strncpy(buf, field->name, ULOGD_MAX_KEYLEN); ++ strncpy(buf, field->name, ULOGD_MAX_KEYLEN-1); ++ buf[ULOGD_MAX_KEYLEN-1] = '\0'; + while ((underscore = strchr(buf, '_'))) + *underscore = '.'; + +@@ -317,7 +337,8 @@ + ulogd_log(ULOGD_ERROR, "OOM!\n"); + return 1; + } +- strncpy(f->name, buf, ULOGD_MAX_KEYLEN); ++ strncpy(f->name, buf, ULOGD_MAX_KEYLEN-1); ++ f->name[ULOGD_MAX_KEYLEN-1] = '\0'; + f->id = id; + f->next = fields; + fields = f; +--- pgsql/ulogd_PGSQL.c ++++ pgsql/ulogd_PGSQL.c 2007/01/10 13:13:23 +@@ -16,6 +16,7 @@ + #include <ulogd/ulogd.h> + #include <ulogd/conffile.h> + #include <libpq-fe.h> ++#include <inttypes.h> + + + #ifdef DEBUG_PGSQL +@@ -39,6 +40,9 @@ + /* buffer for our insert statement */ + static char *stmt; + ++/* size of our insert statement buffer */ ++static size_t stmt_siz; ++ + /* pointer to the beginning of the "VALUES" part */ + static char *stmt_val; + +@@ -120,62 +124,78 @@ + + if (!res || !IS_VALID((*res))) { + /* no result, we have to fake something */ +- sprintf(stmt_ins, "NULL,"); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "NULL,"); + stmt_ins = stmt + strlen(stmt); + continue; + } + + switch (res->type) { + case ULOGD_RET_INT8: +- sprintf(stmt_ins, "%d,", res->value.i8); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%d,", res->value.i8); + break; + case ULOGD_RET_INT16: +- sprintf(stmt_ins, "%d,", res->value.i16); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%d,", res->value.i16); + break; + case ULOGD_RET_INT32: +- sprintf(stmt_ins, "%d,", res->value.i32); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%d,", res->value.i32); + break; + case ULOGD_RET_INT64: +- sprintf(stmt_ins, "%lld,", res->value.i64); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%"PRId64",", res->value.i64); + break; + case ULOGD_RET_UINT8: +- sprintf(stmt_ins, "%u,", res->value.ui8); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%u,", res->value.ui8); + break; + case ULOGD_RET_UINT16: +- sprintf(stmt_ins, "%u,", res->value.ui16); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%u,", res->value.ui16); + break; + case ULOGD_RET_IPADDR: + #ifdef IP_AS_STRING +- *stmt_ins++ = '\''; + 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, "',"); ++ if(stmt_siz > (stmt_ins-stmt)+(strlen(tmpstr)*2)+4) ++ { ++ *stmt_ins++ = '\''; ++ PQescapeString(stmt_ins,tmpstr,strlen(tmpstr)); ++ stmt_ins = stmt + strlen(stmt); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "',"); ++ } ++ else ++ { ++ ulogd_log(ULOGD_NOTICE,"%s: pgsql - no space to add escaped ip string to insert statement\n"); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "'',"); ++ } + break; + #endif /* IP_AS_STRING */ + /* EVIL: fallthrough when logging IP as + * u_int32_t */ + + case ULOGD_RET_UINT32: +- sprintf(stmt_ins, "%u,", res->value.ui32); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%u,", res->value.ui32); + break; + case ULOGD_RET_UINT64: +- sprintf(stmt_ins, "%llu,", res->value.ui64); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "%"PRIu64",", res->value.ui64); + break; + case ULOGD_RET_BOOL: +- sprintf(stmt_ins, "'%d',", res->value.b); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "'%d',", res->value.b); + break; + case ULOGD_RET_STRING: +- *stmt_ins++ = '\''; +- PQescapeString(stmt_ins,res->value.ptr,strlen(res->value.ptr)); +- stmt_ins = stmt + strlen(stmt); +- sprintf(stmt_ins, "',"); ++ if(stmt_siz > (stmt_ins-stmt)+(strlen(res->value.ptr)*2)+4) ++ { ++ *stmt_ins++ = '\''; ++ PQescapeString(stmt_ins,res->value.ptr,strlen(res->value.ptr)); ++ stmt_ins = stmt + strlen(stmt); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "',"); ++ } ++ else ++ { ++ ulogd_log(ULOGD_NOTICE,"%s: pgsql - no space to add escaped string to insert statement\n"); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "'',"); ++ } + break; + case ULOGD_RET_RAW: + ulogd_log(ULOGD_NOTICE,"%s: pgsql doesn't support type RAW\n",res->key); +- sprintf(stmt_ins, "NULL,"); ++ snprintf(stmt_ins, stmt_siz-(stmt_ins-stmt), "NULL,"); + break; + default: + ulogd_log(ULOGD_NOTICE, +@@ -205,12 +225,13 @@ + /* Determine if server support schemas */ + static int pgsql_namespace(void) { + PGresult *result; +- char pgbuf[strlen(PGSQL_HAVE_NAMESPACE_TEMPLATE)+strlen(schema_ce.u.string)+1]; ++ size_t pgbuf_siz = strlen(PGSQL_HAVE_NAMESPACE_TEMPLATE)+strlen(schema_ce.u.string)+1; ++ char pgbuf[pgbuf_siz]; + + if (!dbh) + return 1; + +- sprintf(pgbuf, PGSQL_HAVE_NAMESPACE_TEMPLATE, schema_ce.u.string); ++ snprintf(pgbuf, pgbuf_siz, PGSQL_HAVE_NAMESPACE_TEMPLATE, schema_ce.u.string); + ulogd_log(ULOGD_DEBUG, "%s\n", pgbuf); + + result = PQexec(dbh, pgbuf); +@@ -265,25 +286,27 @@ + ulogd_log(ULOGD_ERROR, "OOM!\n"); + return 1; + } ++ stmt_siz = size; + + if (pgsql_have_schemas) { +- sprintf(stmt, "insert into %s.%s (", schema_ce.u.string, table_ce.u.string); ++ snprintf(stmt, stmt_siz, "insert into %s.%s (", schema_ce.u.string, table_ce.u.string); + } else { +- sprintf(stmt, "insert into %s (", table_ce.u.string); ++ snprintf(stmt, stmt_siz, "insert into %s (", table_ce.u.string); + } + + stmt_val = stmt + strlen(stmt); + + for (f = fields; f; f = f->next) { +- strncpy(buf, f->name, ULOGD_MAX_KEYLEN); ++ strncpy(buf, f->name, ULOGD_MAX_KEYLEN-1); ++ buf[ULOGD_MAX_KEYLEN-1] = '\0'; + while ((underscore = strchr(buf, '.'))) + *underscore = '_'; +- sprintf(stmt_val, "%s,", buf); ++ snprintf(stmt_val, stmt_siz-(stmt_val-stmt), "%s,", buf); + stmt_val = stmt + strlen(stmt); + } + *(stmt_val - 1) = ')'; + +- sprintf(stmt_val, " values ("); ++ snprintf(stmt_val, stmt_siz-(stmt_val-stmt), " values ("); + stmt_val = stmt + strlen(stmt); + + ulogd_log(ULOGD_DEBUG, "stmt='%s'\n", stmt); +@@ -331,7 +354,8 @@ + for (intaux=0; intaux<PQntuples(result); intaux++) { + + /* replace all underscores with dots */ +- strncpy(buf, PQgetvalue(result, intaux, 0), ULOGD_MAX_KEYLEN); ++ strncpy(buf, PQgetvalue(result, intaux, 0), ULOGD_MAX_KEYLEN-1); ++ buf[ULOGD_MAX_KEYLEN-1] = '\0'; + while ((underscore = strchr(buf, '_'))) + *underscore = '.'; + +@@ -350,7 +374,8 @@ + ulogd_log(ULOGD_ERROR, "OOM!\n"); + return 1; + } +- strncpy(f->name, buf, ULOGD_MAX_KEYLEN); ++ strncpy(f->name, buf, ULOGD_MAX_KEYLEN-1); ++ f->name[ULOGD_MAX_KEYLEN-1] = '\0'; + f->id = id; + f->next = fields; + fields = f; +@@ -384,32 +409,34 @@ + if (port) + len += 20; + +- connstr = (char *) malloc(len); ++ connstr = (char *) malloc(len+1); + if (!connstr) + return 1; + + if (server) { +- strcpy(connstr, " host="); +- strcat(connstr, server); ++ strncpy(connstr, " host=", len); ++ connstr[len] = '\0'; ++ strncat(connstr, server, len-strlen(connstr)); + } + + if (port) { + char portbuf[20]; + snprintf(portbuf, sizeof(portbuf), " port=%u", port); +- strcat(connstr, portbuf); ++ strncat(connstr, portbuf, len-strlen(connstr)); + } + +- strcat(connstr, " dbname="); +- strcat(connstr, db); +- strcat(connstr, " user="); +- strcat(connstr, user); ++ strncat(connstr, " dbname=", len-strlen(connstr)); ++ strncat(connstr, db, len-strlen(connstr)); ++ strncat(connstr, " user=", len-strlen(connstr)); ++ strncat(connstr, user, len-strlen(connstr)); + + if (pass) { +- strcat(connstr, " password="); +- strcat(connstr, pass); ++ strncat(connstr, " password=", len-strlen(connstr)); ++ strncat(connstr, pass, len-strlen(connstr)); + } + + dbh = PQconnectdb(connstr); ++ free(connstr); + if (PQstatus(dbh)!=CONNECTION_OK) { + exit_nicely(dbh); + return 1; +--- sqlite3/ulogd_SQLITE3.c ++++ sqlite3/ulogd_SQLITE3.c 2007/01/10 13:13:23 +@@ -55,6 +55,9 @@ + /* buffer for our insert statement */ + static char *stmt; + ++/* size of our insert statement buffer */ ++static size_t stmt_siz; ++ + /* pointer to the final prepared statement */ + static sqlite3_stmt *p_stmt; + +@@ -193,7 +196,7 @@ + static int _sqlite3_createstmt(void) + { + struct _field *f; +- unsigned int size; ++ size_t size; + char buf[ULOGD_MAX_KEYLEN]; + char *underscore; + char *stmt_pos; +@@ -207,7 +210,7 @@ + } + + /* caclulate the size for the insert statement */ +- size = strlen(_SQLITE3_INSERTTEMPL) + strlen(table_ce.u.string); ++ size = strlen(_SQLITE3_INSERTTEMPL) + strlen(table_ce.u.string) + 1; + + DEBUGP("initial size: %u\n", size); + +@@ -230,29 +233,31 @@ + ulogd_log(ULOGD_ERROR, "OOM!\n"); + return 1; + } ++ stmt_siz = size; + +- sprintf(stmt, "insert into %s (", table_ce.u.string); ++ snprintf(stmt, stmt_siz, "insert into %s (", table_ce.u.string); + stmt_pos = stmt + strlen(stmt); + + for (f = fields; f; f = f->next) { +- strncpy(buf, f->name, ULOGD_MAX_KEYLEN); ++ strncpy(buf, f->name, ULOGD_MAX_KEYLEN-1); ++ buf[ULOGD_MAX_KEYLEN-1] = '\0'; + while ((underscore = strchr(buf, '.'))) + *underscore = '_'; +- sprintf(stmt_pos, "%s,", buf); ++ snprintf(stmt_pos, stmt_siz-(stmt_pos-stmt), "%s,", buf); + stmt_pos = stmt + strlen(stmt); + } + + *(stmt_pos - 1) = ')'; + +- sprintf(stmt_pos, " values ("); ++ snprintf(stmt_pos, stmt_siz-(stmt_pos-stmt), " values ("); + stmt_pos = stmt + strlen(stmt); + + for (i = 0; i < col_count - 1; i++) { +- sprintf(stmt_pos,"?,"); ++ snprintf(stmt_pos, stmt_siz-(stmt_pos-stmt), "?,"); + stmt_pos += 2; + } + +- sprintf(stmt_pos, "?)"); ++ snprintf(stmt_pos, stmt_siz-(stmt_pos-stmt), "?)"); + ulogd_log(ULOGD_DEBUG, "stmt='%s'\n", stmt); + + DEBUGP("about to prepare statement.\n"); +@@ -277,7 +282,7 @@ + static int _sqlite3_get_columns(const char *table) + { + char buf[ULOGD_MAX_KEYLEN]; +- char query[SQLITE_SELECT_LEN + CONFIG_VAL_STRING_LEN] = "select * from \0"; ++ char query[SQLITE_SELECT_LEN + CONFIG_VAL_STRING_LEN + 1] = "select * from \0"; + char *underscore; + struct _field *f; + sqlite3_stmt *schema_stmt; +@@ -288,8 +293,8 @@ + if (!dbh) + return 1; + +- strncat(query,table,LINE_LEN); +- ++ strncat(query,table,sizeof(query)-strlen(query)-1); ++ + result = sqlite3_prepare(dbh,query,-1,&schema_stmt,0); + + if (result != SQLITE_OK) +@@ -297,7 +302,8 @@ + + for (column = 0; column < sqlite3_column_count(schema_stmt); column++) { + /* replace all underscores with dots */ +- strncpy(buf, sqlite3_column_name(schema_stmt,column), ULOGD_MAX_KEYLEN); ++ strncpy(buf, sqlite3_column_name(schema_stmt,column), ULOGD_MAX_KEYLEN-1); ++ buf[ULOGD_MAX_KEYLEN-1] = '\0'; + while ((underscore = strchr(buf, '_'))) + *underscore = '.'; + +@@ -316,7 +322,8 @@ + ulogd_log(ULOGD_ERROR, "OOM!\n"); + return 1; + } +- strncpy(f->name, buf, ULOGD_MAX_KEYLEN); ++ strncpy(f->name, buf, ULOGD_MAX_KEYLEN-1); ++ f->name[ULOGD_MAX_KEYLEN-1] = '\0'; + f->id = id; + f->next = fields; + fields = f; +--- extensions/ulogd_PWSNIFF.c.orig 2007-01-30 01:06:52.000000000 +0200 ++++ extensions/ulogd_PWSNIFF.c 2007-01-30 01:07:12.000000000 +0200 +@@ -116,7 +116,7 @@ + return NULL; + } + strncpy(ret[0].value.ptr, (char *)begp, len); +- *((char *)ret[0].value.ptr + len + 1) = '\0'; ++ *((char *)ret[0].value.ptr + len) = '\0'; + } + if (pw_len) { + ret[1].value.ptr = (char *) malloc(pw_len+1); +@@ -126,7 +126,7 @@ + return NULL; + } + strncpy(ret[1].value.ptr, (char *)pw_begp, pw_len); +- *((char *)ret[1].value.ptr + pw_len + 1) = '\0'; ++ *((char *)ret[1].value.ptr + pw_len) = '\0'; + + } + return ret; Modified: ipcop/trunk/updates/2.0.3/ROOTFILES.i486-2.0.3 =================================================================== --- ipcop/trunk/updates/2.0.3/ROOTFILES.i486-2.0.3 2012-01-10 07:46:26 UTC (rev 6227) +++ ipcop/trunk/updates/2.0.3/ROOTFILES.i486-2.0.3 2012-01-11 22:04:27 UTC (rev 6228) @@ -176,6 +176,10 @@ ## tcpdump-4.2.1 /usr/sbin/tcpdump ## +## ulogd-1.24 patched (only changed files) +/usr/lib/ulogd/ulogd_BASE.so +/usr/lib/ulogd/ulogd_SQLITE3.so +## ## usbutils-004 /usr/bin/lsusb /usr/share/usb.ids.gz Modified: ipcop/trunk/updates/2.0.3/information.xml =================================================================== --- ipcop/trunk/updates/2.0.3/information.xml 2012-01-10 07:46:26 UTC (rev 6227) +++ ipcop/trunk/updates/2.0.3/information.xml 2012-01-11 22:04:27 UTC (rev 6228) @@ -6,7 +6,7 @@ <description>Add again capi4k-utils plugins. Add wget.<br /> Disable traffic accounting with detail level High, always use Low.<br /> Patch krb5-1.9.2 against MITKRB5-SA-2011-007.<br /> - More gnupg-1.4.11 hardening.<br /> + More gnupg-1.4.11 hardening. Patched ulogd-1.24.<br /> Language updates.<br /> Upgrade acpid to 2.0.13, bash to 4.2.20, conntrack-tools to 1.0.1, DBD-SQLite to 1.35, diffutils to 3.2, freetype to 2.4.8, gmp to 5.0.2, grep to 2.10, iproute2 to 3.1.0, iptables to 1.4.12.2, iw to 3.2, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox _______________________________________________ Ipcop-svn mailing list Ipcop-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ipcop-svn