summaryrefslogtreecommitdiff
path: root/contrib/chkpass/chkpass.c
diff options
context:
space:
mode:
authorPeter Eisentraut2007-02-07 00:52:35 +0000
committerPeter Eisentraut2007-02-07 00:52:35 +0000
commit16059d39a04f5307e9b4dade10e70e5a4939a6db (patch)
treee9c9a3248870a743e30edbba47c0092ecf8b1832 /contrib/chkpass/chkpass.c
parentf11aa82d0378c48da9fc67e479699a1f8bb99483 (diff)
Replace some strncpy() by strlcpy().
Diffstat (limited to 'contrib/chkpass/chkpass.c')
-rw-r--r--contrib/chkpass/chkpass.c11
1 files changed, 4 insertions, 7 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 @@
* 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);
}