|
|
@ -4,7 +4,7 @@ |
|
|
|
* darcy@druid.net |
|
|
|
* darcy@druid.net |
|
|
|
* http://www.druid.net/darcy/
|
|
|
|
* 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 |
|
|
|
* best viewed with tabs set to 4 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
@ -76,8 +76,7 @@ chkpass_in(PG_FUNCTION_ARGS) |
|
|
|
if (*str == ':') |
|
|
|
if (*str == ':') |
|
|
|
{ |
|
|
|
{ |
|
|
|
result = (chkpass *) palloc(sizeof(chkpass)); |
|
|
|
result = (chkpass *) palloc(sizeof(chkpass)); |
|
|
|
strncpy(result->password, str + 1, 13); |
|
|
|
strlcpy(result->password, str + 1, 13 + 1); |
|
|
|
result->password[13] = 0; |
|
|
|
|
|
|
|
PG_RETURN_POINTER(result); |
|
|
|
PG_RETURN_POINTER(result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -150,8 +149,7 @@ chkpass_eq(PG_FUNCTION_ARGS) |
|
|
|
|
|
|
|
|
|
|
|
if (a2->vl_len < 12) |
|
|
|
if (a2->vl_len < 12) |
|
|
|
sz = a2->vl_len - 4; |
|
|
|
sz = a2->vl_len - 4; |
|
|
|
strncpy(str, a2->vl_dat, sz); |
|
|
|
strlcpy(str, a2->vl_dat, sz + 1); |
|
|
|
str[sz] = 0; |
|
|
|
|
|
|
|
PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) == 0); |
|
|
|
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) |
|
|
|
if (a2->vl_len < 12) |
|
|
|
sz = a2->vl_len - 4; |
|
|
|
sz = a2->vl_len - 4; |
|
|
|
strncpy(str, a2->vl_dat, sz); |
|
|
|
strlcpy(str, a2->vl_dat, sz + 1); |
|
|
|
str[sz] = 0; |
|
|
|
|
|
|
|
PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) != 0); |
|
|
|
PG_RETURN_BOOL(strcmp(a1->password, crypt(str, a1->password)) != 0); |
|
|
|
} |
|
|
|
} |
|
|
|