Skip to content

Commit

Permalink
Fix a portability issue
Browse files Browse the repository at this point in the history
This should fix the following compilation issue:

```
/wrkdirs/usr/ports/security/snuffleupagus/work-php83/snuffleupagus-0.10.0/src/sp_utils.c:438:37: error: too few arguments provided to function-like macro invocation
  438 |     memcpy(mb_name, ZEND_STRL("mb_"));
      |                                     ^
/usr/include/ssp/string.h:117:9: note: macro 'memcpy' defined here
  117 | #define memcpy(dst, src, len) __ssp_bos_check3(memcpy, dst, src, len)
```
  • Loading branch information
jvoisin committed Jun 14, 2024
1 parent 95afce1 commit b005df2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sp_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ bool hook_function(const char* original_name, HashTable* hook_table, zif_handler
if (NULL == mb_name) {
return FAILURE;
}
memcpy(mb_name, ZEND_STRL("mb_"));
memcpy(mb_name + 3, VAR_AND_LEN(original_name));
memcpy(mb_name, "mb_", 3);

This comment has been minimized.

Copy link
@wargio

wargio Jun 15, 2024

Collaborator

if you do just strlen("mb_") the compiler will optimize it out as 3

This comment has been minimized.

Copy link
@wargio

wargio Jun 15, 2024

Collaborator

This comment has been minimized.

Copy link
@jvoisin

jvoisin Jun 15, 2024

Author Owner

Good point.

memcpy(mb_name + 3, original_name, strlen(original_name));
_hook_function(mb_name, hook_table, new_function);
efree(mb_name);
// LCOV_EXCL_STOP
Expand Down

0 comments on commit b005df2

Please sign in to comment.