From: Dan Langille Date: Thu, 18 Dec 2003 17:04:33 +0000 (+0000) Subject: use bstrncpy instead of strcpy. Simlarly for bstrncat. X-Git-Tag: Release-1.34.0~263 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f16c8fc831dce49cfe88cdcc012f9f7ab1e00fa3;p=bacula%2Fbacula use bstrncpy instead of strcpy. Simlarly for bstrncat. Alter my_postgresql_currval to take a table name. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@893 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/postgresql.c b/bacula/src/cats/postgresql.c index 41f7b63572..375be429fc 100644 --- a/bacula/src/cats/postgresql.c +++ b/bacula/src/cats/postgresql.c @@ -524,7 +524,7 @@ void my_postgresql_free_result (B_DB *mdb) { } } -int my_postgresql_currval(B_DB *mdb) { +int my_postgresql_currval(B_DB *mdb, char *table_name) { // Obtain the current value of the sequence that // provides the serial value for primary key of the table. @@ -547,16 +547,16 @@ int my_postgresql_currval(B_DB *mdb) { PGresult *result; int id = 0; - if (strcasecmp(mdb->table_name, "basefiles") == 0) { - strcpy(sequence, "basefiles_baseid"); + if (strcasecmp(table_name, "basefiles") == 0) { + bstrncpy(sequence, "basefiles_baseid", sizeof(sequence)); } else { - strcpy(sequence, mdb->table_name); - strcat(sequence, "_"); - strcat(sequence, mdb->table_name); - strcat(sequence, "id"); + bstrncpy(sequence, table_name, sizeof(sequence)); + bstrncat(sequence, "_", sizeof(sequence)); + bstrncat(sequence, table_name, sizeof(sequence)); + bstrncat(sequence, "id", sizeof(sequence)); } - strcat(sequence, "_seq"); + bstrncat(sequence, "_seq", sizeof(sequence)); bsnprintf(query, sizeof(query), "SELECT currval('%s')", sequence); // Mmsg(&query, "SELECT currval('%s')", sequence);