diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/chkpass/chkpass.c | 11 | ||||
-rw-r--r-- | contrib/dblink/dblink.c | 4 |
2 files changed, 6 insertions, 9 deletions
diff --git a/contrib/chkpass/chkpass.c b/contrib/chkpass/chkpass.c index 0842291eaf7..642212de513 100644 --- a/contrib/chkpass/chkpass.c +++ b/contrib/chkpass/chkpass.c @@ -4,7 +4,7 @@ * darcy@druid.net * http://www.druid.net/darcy/ * - * $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.17 2006/07/14 05:28:27 tgl Exp $ + * $PostgreSQL: pgsql/contrib/chkpass/chkpass.c,v 1.18 2007/02/07 00:52:35 petere Exp $ * best viewed with tabs set to 4 */ @@ -76,8 +76,7 @@ chkpass_in(PG_FUNCTION_ARGS) if (*str == ':') { result = (chkpass *) palloc(sizeof(chkpass)); - strncpy(result->password, str + 1, 13); - result->password[13] = 0; + strlcpy(result->password, str + 1, 13 + 1); PG_RETURN_POINTER(result); } @@ -150,8 +149,7 @@ chkpass_eq(PG_FUNCTION_ARGS) if (a2->vl_len < 12) sz = a2->vl_len - 4; - strncpy(str, a2->vl_dat, sz); - str[sz] = 0; + strlcpy(str, a2->vl_dat, sz + 1); PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) == 0); } @@ -166,7 +164,6 @@ chkpass_ne(PG_FUNCTION_ARGS) if (a2->vl_len < 12) sz = a2->vl_len - 4; - strncpy(str, a2->vl_dat, sz); - str[sz] = 0; + strlcpy(str, a2->vl_dat, sz + 1); PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) != 0); } diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index f4c06624060..568ac1e5f73 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -8,7 +8,7 @@ * Darko Prenosil <Darko.Prenosil@finteh.hr> * Shridhar Daithankar <shridhar_daithankar@persistent.co.in> * - * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.61 2007/01/05 22:19:17 momjian Exp $ + * $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.62 2007/02/07 00:52:35 petere Exp $ * Copyright (c) 2001-2007, PostgreSQL Global Development Group * ALL RIGHTS RESERVED; * @@ -2248,7 +2248,7 @@ createNewConnection(const char *name, remoteConn * rconn) errmsg("duplicate connection name"))); hentry->rconn = rconn; - strncpy(hentry->name, name, NAMEDATALEN - 1); + strlcpy(hentry->name, name, sizeof(hentry->name)); } static void |