@@ -1146,6 +1146,10 @@ DBGP_FUNC(eval)
11461146 /* base64 decode eval string */
11471147 eval_string = (char * ) xdebug_base64_decode ((unsigned char * ) CMD_OPTION_CHAR ('-' ), CMD_OPTION_LEN ('-' ), & new_length );
11481148
1149+ if (!eval_string ) {
1150+ RETURN_RESULT_WITH_MESSAGE (XG_DBG (status ), XG_DBG (reason ), XDEBUG_ERROR_EVALUATING_CODE , xdebug_sprintf ("%s: %s" , error_message_from_code (XDEBUG_ERROR_EVALUATING_CODE ), "invalid base64-encoded data value" ));
1151+ }
1152+
11491153 res = xdebug_do_eval (eval_string , & ret_zval , & return_message );
11501154
11511155 xdfree (eval_string );
@@ -1273,9 +1277,25 @@ DBGP_FUNC(detach)
12731277 XG_DBG (stdout_mode ) = 0 ;
12741278 XG_DBG (detached ) = 1 ;
12751279
1276- if (CMD_OPTION_SET ('-' )) {
1277- XG_DBG (context ).detached_message = xdstrdup (CMD_OPTION_CHAR ('-' ));
1278- xdebug_log_ex (XLOG_CHAN_DEBUG , XLOG_WARN , "DETACH" , "Debug client detached: %s." , XG_DBG (context ).detached_message );
1280+ if (CMD_OPTION_SET ('-' ) && CMD_OPTION_LEN ('-' ) > 0 ) {
1281+ unsigned char * new_value ;
1282+ size_t new_length = 0 ;
1283+
1284+ /* It should be base64 */
1285+ new_value = xdebug_base64_decode ((unsigned char * ) CMD_OPTION_CHAR ('-' ), CMD_OPTION_LEN ('-' ), & new_length );
1286+
1287+ /* But if not, we fall back if all characters are also printable. */
1288+ if (new_value ) {
1289+ if (xdebug_is_printable ((char * ) new_value , new_length )) {
1290+ XG_DBG (context ).detached_message = (char * ) new_value ;
1291+ } else {
1292+ xdfree (new_value );
1293+ XG_DBG (context ).detached_message = xdstrdup (CMD_OPTION_CHAR ('-' ));
1294+ }
1295+ } else {
1296+ XG_DBG (context ).detached_message = xdstrdup (CMD_OPTION_CHAR ('-' ));
1297+ }
1298+ xdebug_log_ex (XLOG_CHAN_DEBUG , XLOG_WARN , "DETACH" , "Debug client detached: %s" , XG_DBG (context ).detached_message );
12791299 }
12801300}
12811301
@@ -1724,6 +1744,10 @@ DBGP_FUNC(property_set)
17241744
17251745 new_value = xdebug_base64_decode ((unsigned char * ) CMD_OPTION_CHAR ('-' ), CMD_OPTION_LEN ('-' ), & new_length );
17261746
1747+ if (!new_value ) {
1748+ RETURN_RESULT_WITH_MESSAGE (XG_DBG (status ), XG_DBG (reason ), XDEBUG_ERROR_EVALUATING_CODE , xdebug_sprintf ("%s: %s" , error_message_from_code (XDEBUG_ERROR_EVALUATING_CODE ), "invalid base64-encoded data value" ));
1749+ }
1750+
17271751 /* Set a cast, if requested through the 't' option */
17281752 cast_as = "" ;
17291753
0 commit comments