phpredis icon indicating copy to clipboard operation
phpredis copied to clipboard

Wrong usage of string length

Open laruence opened this issue 8 years ago • 0 comments

Seems all string length uses int , which should introduce problems (segfault etc) after parameters parsing...

like:

/* {{{ proto array Redis::info() */
PHP_METHOD(Redis, info) {

    zval *object;
    RedisSock *redis_sock;
    char *cmd, *opt = NULL;
    int cmd_len, opt_len;

    if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(),
                "O|s", &object, redis_ce, &opt, &opt_len)
            == FAILURE)
    {
        RETURN_FALSE;
    }

opt_len should be size_t here.

and actually, it's better to use zend_string instead ("S")...

thanks

laruence avatar Jul 18 '15 08:07 laruence