Skip to content

Commit 1f4660e

Browse files
ZEND_STRTOL
1 parent 5313b87 commit 1f4660e

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

php7/memcache.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,11 @@ ZEND_GET_MODULE(memcache)
139139

140140
static PHP_INI_MH(OnUpdateChunkSize) /* {{{ */
141141
{
142-
long int lval;
142+
zend_long val;
143+
char *endptr = NULL;
143144

144-
lval = strtol(ZSTR_VAL(new_value), NULL, 10);
145-
if (lval <= 0) {
145+
val = ZEND_STRTOL(ZSTR_VAL(new_value), &endptr, 10);
146+
if (!endptr || (*endptr != '\0') || val <= 0) {
146147
php_error_docref(NULL, E_WARNING, "memcache.chunk_size must be a positive integer ('%s' given)", ZSTR_VAL(new_value));
147148
return FAILURE;
148149
}
@@ -153,10 +154,11 @@ static PHP_INI_MH(OnUpdateChunkSize) /* {{{ */
153154

154155
static PHP_INI_MH(OnUpdateFailoverAttempts) /* {{{ */
155156
{
156-
long int lval;
157+
zend_long val;
158+
char *endptr = NULL;
157159

158-
lval = strtol(ZSTR_VAL(new_value), NULL, 10);
159-
if (lval <= 0) {
160+
val = ZEND_STRTOL(ZSTR_VAL(new_value), &endptr, 10);
161+
if (!endptr || (*endptr != '\0') || val <= 0) {
160162
php_error_docref(NULL, E_WARNING, "memcache.max_failover_attempts must be a positive integer ('%s' given)", ZSTR_VAL(new_value));
161163
return FAILURE;
162164
}
@@ -218,10 +220,11 @@ static PHP_INI_MH(OnUpdateHashFunction) /* {{{ */
218220

219221
static PHP_INI_MH(OnUpdateRedundancy) /* {{{ */
220222
{
221-
long int lval;
223+
zend_long val;
224+
char *endptr = NULL;
222225

223-
lval = strtol(ZSTR_VAL(new_value), NULL, 10);
224-
if (lval <= 0) {
226+
val = ZEND_STRTOL(ZSTR_VAL(new_value), &endptr, 10);
227+
if (!endptr || (*endptr != '\0') || val <= 0) {
225228
php_error_docref(NULL, E_WARNING, "memcache.redundancy must be a positive integer ('%s' given)", ZSTR_VAL(new_value));
226229
return FAILURE;
227230
}
@@ -232,10 +235,11 @@ static PHP_INI_MH(OnUpdateRedundancy) /* {{{ */
232235

233236
static PHP_INI_MH(OnUpdateCompressThreshold) /* {{{ */
234237
{
235-
long int lval;
238+
zend_long val;
239+
char *endptr = NULL;
236240

237-
lval = strtol(ZSTR_VAL(new_value), NULL, 10);
238-
if (lval < 0) {
241+
val = ZEND_STRTOL(ZSTR_VAL(new_value), &endptr, 10);
242+
if (!endptr || (*endptr != '\0') || val < 0) {
239243
php_error_docref(NULL, E_WARNING, "memcache.compress_threshold must be a positive integer ('%s' given)", ZSTR_VAL(new_value));
240244
return FAILURE;
241245
}
@@ -246,10 +250,11 @@ static PHP_INI_MH(OnUpdateCompressThreshold) /* {{{ */
246250

247251
static PHP_INI_MH(OnUpdateLockTimeout) /* {{{ */
248252
{
249-
long int lval;
253+
zend_long val;
254+
char *endptr = NULL;
250255

251-
lval = strtol(ZSTR_VAL(new_value), NULL, 10);
252-
if (lval <= 0) {
256+
val = ZEND_STRTOL(ZSTR_VAL(new_value), &endptr, 10);
257+
if (!endptr || (*endptr != '\0') || val <= 0) {
253258
php_error_docref(NULL, E_WARNING, "memcache.lock_timeout must be a positive integer ('%s' given)", ZSTR_VAL(new_value));
254259
return FAILURE;
255260
}

0 commit comments

Comments
 (0)