summaryrefslogtreecommitdiffstats
path: root/output/dbi/ulogd_output_DBI.c
Commit message (Collapse)AuthorAgeFilesLines
* output: DBI: fix configuration of DB connectionJeremy Sowden2021-12-061-7/+7
| | | | | | | | | | In `open_db_dbi`, we test whether various config-settings are defined by comparing their string values to `NULL`. However, the `u.string` member of `struct config_entry` is an array, not a pointer, so it is never `NULL`. Instead, check whether the string is empty. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* output: DBI: fix NUL-termination of escaped SQL stringJeremy Sowden2021-12-061-4/+6
| | | | | | | | | | | | On error, `dbi_conn_quote_string_copy` returns zero. In this case, we need to set `*dst` to NUL. Handle a return-value of `2` as normal below. `1` is never returned. Replace `strncpy` with `memcpy`: using `strncpy` is nearly always a mistake, and we don't need its special behaviour here. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* output: DBI: improve mapping of DB columns to input-keysJeremy Sowden2021-11-301-21/+13
| | | | | | | | | | | | | | | | | | | | | | | | Currently, we copy the column-name to a buffer, iterate over it to replace the underscores with full-stops, using `strchr` from the start of the buffer on each iteration, iterate over it a second time to lower-case all letters, and finally copy the buffer to the input-key's `name` member. In addition to being inefficient, `strncpy` is used to do the copies, which leads gcc to complain: ulogd_output_DBI.c:160:17: warning: `strncpy` output may be truncated copying 31 bytes from a string of length 31 Furthermore, the buffer is not initialized, which means that there is also a possible buffer overrun if the column-name is too long, since `strncpy` will not append a NUL. Instead, copy the column-name directly to the input-key using `snprintf`, and then iterate over it once to replace underscores and lower-case letters. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* output: DBI: fix deprecation warningsJeremy Sowden2021-11-301-7/+11
| | | | | | | | | | | | | The DBI output plugin uses some libdbi functions which have been deprecated in favour of re-entrant equivalents. Switch to the re-entrant functions. Remove superfluous `init` declaration. Add destructor to clean up DBI instance on exit. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* Replace malloc+memset with callocJeremy Sowden2021-11-301-5/+1
| | | | | | | | There are a number of places where we `malloc` some memory and then `memset` it to zero. Use `calloc` instead. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* src: fix version that -V displaysPablo Neira Ayuso2012-08-031-1/+1
| | | | | | | It was wrong, use VERSION constant which uses the version information available in configure.ac. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* ulogd2 / DBI / table nameHarald Welte2012-02-241-1/+4
| | | | | | | | | | | | | DBI: allow to define table name via table config option While using the DBI plugin of ulogd2 for NFCT based accounting, despite using table="conntrack", it always insisted in using the table "ulog" for deriving the keys/columns to be stored. I've hacked up a quick fix, and it seems to work as expected (though no proper null termination after strncpy). Signed-off-by: Harald Welte <laforge@netfilter.org>
* DBI: lower column name before comparing to keyPierre Chifflier2009-01-071-0/+14
| | | | | | | Some databases (e.g Oracle) return column name in uppercase, while key name is in lowercase. This patch allows to match keys correctly. Signed-off-by: Pierre Chifflier <chifflier@inl.fr>
* Add new output plugin DBIPierre Chifflier2008-12-091-0/+313
libdbi implements a database-independent abstraction layer in C, similar to the DBI/DBD layer in Perl. This module brings support for all database types supported by libdbi. Signed-off-by: Pierre Chifflier <chifflier@inl.fr> Signed-off-by: Eric Leblond <eric@inl.fr>