summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2013-10-24 20:26:45 +0000
committereric <eric@openbsd.org>2013-10-24 20:26:45 +0000
commit4ee93bf491db4ab837aa206c9b7d81c3e77003eb (patch)
treeae49445f5928db0a43e6cde6c6c8ce28ebb77cb1
parentfix leaks on update (diff)
downloadwireguard-openbsd-4ee93bf491db4ab837aa206c9b7d81c3e77003eb.tar.xz
wireguard-openbsd-4ee93bf491db4ab837aa206c9b7d81c3e77003eb.zip
fix USERINFO and CREDENTIALS lookups in experimental sqlite backend.
-rw-r--r--usr.sbin/smtpd/table_sqlite.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.sbin/smtpd/table_sqlite.c b/usr.sbin/smtpd/table_sqlite.c
index 3a4875c1337..870341ac81d 100644
--- a/usr.sbin/smtpd/table_sqlite.c
+++ b/usr.sbin/smtpd/table_sqlite.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table_sqlite.c,v 1.6 2013/07/22 13:14:49 eric Exp $ */
+/* $OpenBSD: table_sqlite.c,v 1.7 2013/10/24 20:26:45 eric Exp $ */
/*
* Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
@@ -154,7 +154,7 @@ table_sqlite_update(void)
{ "query_domain", 1 },
{ "query_credentials", 2 },
{ "query_netaddr", 1 },
- { "query_userinfo", 4 },
+ { "query_userinfo", 3 },
{ "query_source", 1 },
{ "query_mailaddr", 1 },
{ "query_addrname", 1 },
@@ -353,7 +353,7 @@ table_sqlite_query(const char *key, int service)
stmt = NULL;
for(i = 0; i < SQL_MAX; i++)
- if (service == 1 << i) {
+ if (service == (1 << i)) {
stmt = statements[i];
break;
}
@@ -450,11 +450,10 @@ table_sqlite_lookup(int service, const char *key, char *dst, size_t sz)
}
break;
case K_USERINFO:
- if (snprintf(dst, sz, "%s:%i:%i:%s",
- sqlite3_column_text(stmt, 0),
+ if (snprintf(dst, sz, "%i:%i:%s",
+ sqlite3_column_int(stmt, 0),
sqlite3_column_int(stmt, 1),
- sqlite3_column_int(stmt, 2),
- sqlite3_column_text(stmt, 3)) > (ssize_t)sz) {
+ sqlite3_column_text(stmt, 2)) > (ssize_t)sz) {
log_warnx("warn: table-sqlite: result too large");
r = -1;
}
@@ -474,6 +473,7 @@ table_sqlite_lookup(int service, const char *key, char *dst, size_t sz)
r = -1;
}
+ sqlite3_reset(stmt);
return (r);
}