1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Replace some strncpy() by strlcpy().

This commit is contained in:
Peter Eisentraut
2007-02-07 00:52:35 +00:00
parent f11aa82d03
commit 16059d39a0
8 changed files with 20 additions and 30 deletions

View File

@ -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);
}