Skip to content

Commit

Permalink
Merge pull request #174 from remicollet/issue-172
Browse files Browse the repository at this point in the history
fix #172 provider/token may be not nul terminated
  • Loading branch information
laruence authored May 5, 2022
2 parents a53566d + bef1378 commit 13df6c9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions yar_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,16 @@ static inline int php_yar_server_auth(zval *obj, yar_header_t *header, yar_respo
YAR_TRY {
zval auth_params[2];

ZVAL_STRINGL(&auth_params[0], (char*)header->provider, MIN(strlen(header->provider), 32));
ZVAL_STRINGL(&auth_params[1], (char*)header->token, MIN(strlen(header->token), 32));
if (memchr(header->provider, 0, 32)) {
ZVAL_STRINGL(&auth_params[0], (char*)header->provider, strlen((char *)header->provider));
} else {
ZVAL_STRINGL(&auth_params[0], (char*)header->provider, 32);
}
if (memchr(header->token, 0, 32)) {
ZVAL_STRINGL(&auth_params[1], (char*)header->token, strlen((char*)header->token));
} else {
ZVAL_STRINGL(&auth_params[1], (char*)header->token, 32);
}

#if PHP_VERSION_ID < 80000
zend_call_method_with_2_params(obj, ce, NULL, "__auth", &ret, auth_params, auth_params + 1);
Expand Down

0 comments on commit 13df6c9

Please sign in to comment.