7676#define PHONGO_DEBUG_INI_DEFAULT ""
7777#define PHONGO_METADATA_SEPARATOR " / "
7878#define PHONGO_METADATA_SEPARATOR_LEN (sizeof(PHONGO_METADATA_SEPARATOR) - 1)
79+ #define PHONGO_METADATA_PHP_VERSION_PREFIX "PHP "
80+ #define PHONGO_METADATA_PHP_VERSION_PREFIX_LEN (sizeof(PHONGO_METADATA_PHP_VERSION_PREFIX) - 1)
7981
8082ZEND_DECLARE_MODULE_GLOBALS (mongodb )
8183#if defined(ZTS ) && defined(COMPILE_DL_MONGODB )
@@ -2565,20 +2567,20 @@ static bool php_phongo_extract_handshake_data(zval* driver, const char* key, cha
25652567static char * php_phongo_concat_handshake_data (const char * default_value , const char * custom_value , size_t custom_value_len )
25662568{
25672569 char * ret ;
2568- /* Length of the returned value needs to include the trailing null byte */
2569- size_t ret_len = strlen (default_value ) + 1 ;
2570+ /* Length of the returned value needs to include a trailing space and null byte */
2571+ size_t ret_len = strlen (default_value ) + 2 ;
25702572
25712573 if (custom_value ) {
2572- /* Increase the length by that of the custom value as well as one byte for the separator */
2574+ /* Increase the length by that of the custom value as well as the separator length */
25732575 ret_len += custom_value_len + PHONGO_METADATA_SEPARATOR_LEN ;
25742576 }
25752577
25762578 ret = ecalloc (sizeof (char * ), ret_len );
25772579
25782580 if (custom_value ) {
2579- snprintf (ret , ret_len , "%s%s%s" , default_value , PHONGO_METADATA_SEPARATOR , custom_value );
2581+ snprintf (ret , ret_len , "%s%s%s " , default_value , PHONGO_METADATA_SEPARATOR , custom_value );
25802582 } else {
2581- snprintf (ret , ret_len , "%s" , default_value );
2583+ snprintf (ret , ret_len , "%s " , default_value );
25822584 }
25832585
25842586 return ret ;
@@ -2592,16 +2594,16 @@ static void php_phongo_handshake_data_append(const char* name, size_t name_len,
25922594 char * driver_version ;
25932595 char * full_platform ;
25942596
2595- php_version_string_len = strlen (PHP_VERSION );
2596- php_version_string = ecalloc (sizeof (char * ), 4 + php_version_string_len );
2597- snprintf (php_version_string , 4 + php_version_string_len , "PHP %s" , PHP_VERSION );
2597+ php_version_string_len = strlen (PHP_VERSION ) + PHONGO_METADATA_PHP_VERSION_PREFIX_LEN + 1 ;
2598+ php_version_string = ecalloc (sizeof (char * ), php_version_string_len );
2599+ snprintf (php_version_string , php_version_string_len , "%s%s" , PHONGO_METADATA_PHP_VERSION_PREFIX , PHP_VERSION );
25982600
25992601 driver_name = php_phongo_concat_handshake_data ("ext-mongodb:PHP" , name , name_len );
26002602 driver_version = php_phongo_concat_handshake_data (PHP_MONGODB_VERSION , version , version_len );
26012603 full_platform = php_phongo_concat_handshake_data (php_version_string , platform , platform_len );
26022604
26032605 MONGOC_DEBUG (
2604- "Setting driver handshake data: name %s , version %s , platform %s " ,
2606+ "Setting driver handshake data: { name: '%s' , version: '%s' , platform: '%s' } " ,
26052607 driver_name ,
26062608 driver_version ,
26072609 full_platform );
0 commit comments