$NetBSD: patch-ae,v 1.1 2009/03/13 10:11:15 roy Exp $ Report the correct driver on error. Escape the binary string correctly using the thread safe PQescapeByteaConn. Declare the string as being escaped. Use strlcpy instead of strcpy. --- src/pgsql_drv.c 2006-07-29 14:38:48.000000000 +0100 +++ src/pgsql_drv.c 2009-03-12 23:19:50.000000000 +0000 @@ -1146,7 +1146,7 @@ p = _pgsql_drv_getpwuid (CTX, uid); if (!p) { - LOG(LOG_CRIT, "_ds_get_signature(): _mysql_drv_getpwuid(%d) failed: aborting", uid); + LOG(LOG_CRIT, "_ds_get_signature(): _pgsql_drv_getpwuid(%d) failed: aborting", uid); return EFAILURE; } username = strdup(p->pw_name); @@ -1238,10 +1238,10 @@ return EUNKNOWN; } - mem = PQescapeBytea(SIG->data, SIG->length, &length); + mem = PQescapeByteaConn(s->dbh, SIG->data, SIG->length, &length); snprintf (scratch, sizeof (scratch), - "INSERT INTO dspam_signature_data (uid, signature, length, created_on, data) VALUES (%d, '%s', %ld, CURRENT_DATE, '", + "INSERT INTO dspam_signature_data (uid, signature, length, created_on, data) VALUES (%d, '%s', %ld, CURRENT_DATE, E'", (int)p->pw_uid, signature, SIG->length); buffer_cat (query, scratch); buffer_cat (query, (const char *) mem); @@ -1405,7 +1405,7 @@ virtual_username, virtual_table); #else - strcpy (query, "DECLARE dscursor CURSOR FOR SELECT DISTINCT uid FROM dspam_stats"); + strlcpy (query, "DECLARE dscursor CURSOR FOR SELECT DISTINCT uid FROM dspam_stats", sizeof(query)); #endif result = PQexec(s->dbh, query);