Skip to content

fix build warning #417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2018
Merged

Conversation

remicollet
Copy link
Collaborator

@remicollet remicollet commented Dec 21, 2018

/work/GIT/php-memcached/php_memcached.c: In function 's_stat_execute_cb':
/work/GIT/php-memcached/php_memcached.c:2755:27: warning: field precision specifier '.*' expects argument of type 'int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Wformat=]
  spprintf (&buffer, 0, "%.*s", value_length, value);
                         ~~^~   ~~~~~~~~~~~~

@@ -2752,7 +2752,7 @@ memcached_return s_stat_execute_cb (php_memcached_instance_st instance, const ch
server_values = zend_hash_add(Z_ARRVAL_P(return_value), server_key, &zv);
}

spprintf (&buffer, 0, "%.*s", value_length, value);
spprintf (&buffer, 0, "%.*s", (int)value_length, value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, this needs to be clamped to INT_MAX for safety. In practice a number that large (or negative wraparound!) won't happen or will crash elsewhere anyways.

@sodabrew sodabrew added this to the 3.1.1 milestone Dec 22, 2018
@sodabrew sodabrew merged commit 3529243 into php-memcached-dev:master Dec 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants